0% found this document useful (0 votes)
20 views5 pages

Revision 8 LOOPS

The document contains code snippets that use for loops and if/else statements to output numbers and characters in specific patterns.

Uploaded by

Shady Maged
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views5 pages

Revision 8 LOOPS

The document contains code snippets that use for loops and if/else statements to output numbers and characters in specific patterns.

Uploaded by

Shady Maged
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 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