You are on page 1of 5

Trace

for (int k = 1; k<30; k++)


if (k % 5 = = 0 || k % 7 = = 0)
cout<<setw(3)<< k+1;
cout<<endl;

Output
int nm;
const int one = 1;
const int two = 2;
const int three = 3;

for (int n = 1; n < 10; n++)


{
switch (n % three)
{
case 1:
nm = one;
break;
case 2:
nm = two;
break;
default:
nm = three;
}
for (int m = 1; m <= n; m++)
cout << nm;
cout << endl;
}
Write a program segment
1
12
***
1234
12345
******
1234567
12345678
*********
Write a program segment
*
*
*
*
*
*
*
*
*
Write a program segment
**********
*********
********
*******
******
*****
****
***
**
*

You might also like