0% found this document useful (0 votes)
31 views

P 9.2class Diagram

The document shows examples of using nested for loops in C++ to print various patterns. It includes code snippets that use nested for loops to print out rows of asterisks in different formats, numbers increasing in size on subsequent rows, and numbers arranged in a triangular pattern. The document also provides an example of a task to create a program that outputs a specific numeric pattern using nested for loops.

Uploaded by

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

P 9.2class Diagram

The document shows examples of using nested for loops in C++ to print various patterns. It includes code snippets that use nested for loops to print out rows of asterisks in different formats, numbers increasing in size on subsequent rows, and numbers arranged in a triangular pattern. The document also provides an example of a task to create a program that outputs a specific numeric pattern using nested for loops.

Uploaded by

alifyanaurma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Pencarian Manual Perulangan

for(i = 0; i <= 3; i++)


{
for(j = 0; j <= 2; j++)
{
cout<< i<< " " <<j<< endl;
}
}

Memory Screen
int i int j 0 0
0 1
0 0
0 2
1 1 0
2 1 1
1 2
3 end loop
2 0
1 0 2 1
1 2 2
3 0
2
3 1
3 end loop 3 2
2 0
1
2
3 end loop
3 0
1
2
3 end loop
4 end loop
#include<iostream>
using namespace std;
int main()
{
int i,j;
for(i=1; i<=4; i++)
{
for(j=1; j<=10; j++)
cout<<'*';
cout<<endl;
}
return 0;
}
Hasil:
**********
**********
**********
**********

#include<iostream>
using namespace std;
int main()
{ int i,j,k;
for(i=1; i<=5; i++)
{ for(j=5; j>i; j--)
cout<<' ';
for(k=1; k<=i; k++)
cout<<'*';
cout<<endl;
}return 0;
}
Hasil:
*
**
***
****
*****

#include<iostream>
using namespace std;
int main()
{ int i,j,k;
for(i=1; i<=5; i++)
{ for(j=5; j>i; j--)
cout<<' ';
for(k=1; k<2*i; k++)
cout<<'*';
cout<<endl;
}return 0;
}

Hasil:
*
***
*****
*******
*********

#include<iostream>
using namespace std;
int main()
{ int i,j,k;
for(i=1; i<=5; i++)
{ for(j=5; j>i; j--)
cout<<' ';
for(k=1; k<2*i; k++)
cout<<i;
cout<<endl;
}return 0;
}

Hasil:
1
222
33333
4444444
555555555

*. Tugas buat program C++ dengan hasil sbb:


1
212
32123
4321234
543212345

You might also like