0
In the cout statement, why is this array of size x? Since it's an int array doesn't the size also have to be an integer??
//prints myArray's elements using a for loop int myArray[4]= {1,2,3,4}; For (int x=0; x < 4; x++) { cout << myArray[x] << endl; }
2 Antworten
+ 1
u wrote a loop to loop through the array elements from 0-3. The x is there to represent the value of the of the array elements. so basically, when x=0, the console output will be 1, when x is 1, the console output will be 2..., this will continue until it fulfills the condition: for x < 4.
0
As the size of an instance could theoretically be the whole address space a type is used that is equivalent to the size of addresses on the target system. Addresses on the target system are always the size of an int as ints have exactly the size of a hardware register on the target system (at least as far as I know on a x86 architecture) .
*unsigned* int since something can't take up negative space and unsigned ints are actually used to address memory on the hardware.