Please explain to me on how to get the out for this code:
1 2 3 4 5 6 7 8 9
|
int list [10], i, j;
for ( i = 9; i >= 0; --i )
{
list [i] = i * 100 – 5;
if ( i % 3 == 1 ) list [i] = list [i+1] * 200;
}
for ( j = 0; j < 10; ++j ) cout << list[j]+ " " ;
cout << endl;
|
2)Assume you have an array called “nums” that has 20 integers in it. Also, assume that it is
populated already. Write the code to display the values in “nums” with 4 numbers on each
line separated by a couple of blank spaces.
{ I.e. you will have 5 lines printed, 4 numbers on each line. }
Do NOT reference 4 values of “nums” in one “cout” statement.
For example, do NOT write something like this:
cout << nums[1] << nums[2] << nums[3] << nums[4] <<endl;.
Do not write something like the above using a variable or an expression instead of the
numbers in the subscripts.
Hint: you are using the "typical" loop and printing nums[i] in one cout.
Consider when do you print blank spaces VS when to go to the next line.
From what i understood, this is what i have:
1 2 3
|
int nums[20];
for(i=20;>=0,++i);
( list [20]=i
|
Not sure where to go from here...