int * gred ;
gred = new int [100] ; // this example snippet creates 100 ints
To dynamically allocate memory, use the following function (stdlib.h I believe): int *variable1 = malloc(sizeof(int));
Pointers are data types that hold integer values, those "integer" values are simply addresses of another variables.Example:int x = 15; // this is an integer variable with value 15int* ptr; // this is a pointer to an integerptr = &x; // now we assigned the address of x to the pointer ptr// if you want to access the value of x (15 in this example),// you should use the deterrence *// so you can say:printf("%d", *ptr); // this will print 15// you can print the value of ptr (which is the address of x) using:printf("%p", ptr); // this will print an integer, which is the address of x.==========================================================More explanation, let's imagine that this is a memory:-00--01-02-03-04 =====> these are the address of the memory|--- |--- |---|---|---| =====> values inside the memoryFor the example I gave before, let's imagine the following:-00-01-02--03--04|---|15|--- | 01 |---|------x------- ptrAs you can see, x hold the value 15, ptr holds the value 01 which is actually the address of x. Now ptr have a distinct address too, which is 03.In reality, the address of a memory is longer, and usually represented as hexadecimal values. example 0x002154You can find more information here:http://en.wikipedia.org/wiki/Pointers
Data type is mandatory in every variable-declaration.Example:int i; -- integerint *pi; -- integer-pointerint ai[10]; -- integer-arrayint *api[10]; -- array of integer-pointersint (*api)[10]; -- pointer to integer-array
A pointer holds a memory address, from 0 to the upper limit of your memory (in 32 bit addressing this is up to 2^32, 64 bit is up to 2^64 bytes). So in math terms, a pointer could be considered a non-negative integer. However this is not the same as the integer type used in C and other languages, which refers to how the data at that memory address (the raw bits) is interpreted by the system. So the expression "int *x;" declares a pointer to an integer, but x is a memory address, not a literal C-style integer. The value pointed to by x, however, will be interpreted as a literal C-style integer. It may be easier to see using a pointer to a char: char character = 'C'; char *pointerToCharacter = character; In this case, character is a standard char variable, and pointerToCharacter is a pointer (which is a memory address) that points to the location in memory of a character.
C++ Provides a multiple branch selection called as switch. This selection statement succesively test against a list of integer or character constants. When a match is found the statements associate with constants are executed. When no match is found default statement is used.
To dynamically allocate memory, use the following function (stdlib.h I believe): int *variable1 = malloc(sizeof(int));
the square of an integer will always be an integer
The statement is not true. Disprove by counter-example: 3 is an integer and 5 is an integer, their product is 15 which is odd.
Any fraction p/q where p is an integer and q is a non-zero integer is rational.
5
The statement is false.
True. The first statement is true and the second statement is false. In a disjunction, if either statement is true, the disjunction is true.
The let statement is: let the smallest of the three integers be x.
It is an invalid statement.
"Arbitrary" simply means any. So this refers to any positive integer. It may be used to make a statement that is true for every positive integer.
The statement is: "Their sum is always an integer." Whether the sum is negative or positive depends on the two original integers.
Not necessarily, for example: If you subtract 3 from 4, then you get +1. But if you subtract 4 from 3, you get -1. The answer will always be an integer, but you cannot make a general statement about the sign, without knowing more information.