You are on page 1of 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