Wyo C++ Ch. 8 Worksheet #2 |
Name - |
Do the following exercises on lined paper. Do not use a C++ compiler. Neatly show the displayed output in a diagram as well as the intermediate values (running list of values in column form) of all variables cited in the code segments below. You may use dots (i.e. ellipsis) to show a pattern but be sure to show all final values.
1.
int i = 0;
int k = 0;
for ( i = 19; i >= 6; i -= 4)
{
cout << i << endl;
for (k = 0; k < 3; k++)
{
cout << (i
+ k) << endl;
}
}
2.
int number = 9;
int i = 0;
while (number > 5)
{
number--;
for (i = 1; i < 10; i++)
{
cout <<
number * i << endl;
if ( i % 6
= = 0)
{
break;
number
= -9;
}
else
{
continue;
}
}
}