Buat belajar teman-teman yang serius belajar :
gw kasih coding tugas-tugas looping yang waktu itu di kasih bu hera :
#include<iostream.h>
void main()
{
char x,y,spasi,a,b;
for (x='a';x<='e';x++)
{
for (spasi='e';spasi>=x;spasi--)
cout<<' ';
for (y='a';y<=x;y++)
{
cout<<y;
}
cout<<endl;
}
for (a='d';a>='a';a--)
{ cout<<' ';
for (spasi='d';spasi>=a;spasi--)
cout<<' ';
for (b='a';b<=a;b++)
{
cout<<b;
}
cout<<endl;
}
}
output :
#include<iostream.h>
#include<conio.h>
void main()
{
char x,y,spasi;
for (x='e';x>='a';x--)
{
for (spasi='e';spasi>=x;spasi--)
cout<<' ';
for (y='a';y<=x;y++)
{
cout<<' '<<y;
}
cout<<endl;
}
}
Output :
#include<iostream.h>
#include<conio.h>
void main()
{
char x,y,spasi;
for (x='a';x<='e';x++)
{
for (spasi='e';spasi>=x;spasi--)
cout<<' ';
for (y='a';y<=x;y++)
{
cout<<' '<<y;
}
cout<<endl;
}
}
#include<iostream.h>
void main()
{
char hrf1,hrf2,hrf3,hrf4;
for(hrf1='a';hrf1<='e';hrf1++)
{
for(hrf2='a';hrf2<=hrf1;hrf2++)
{ cout<<hrf2;
cout<<' ';
}
cout<<endl;
}
for(hrf3='d';hrf3>='a';hrf3--)
{
for(hrf4='a';hrf4<=hrf3;hrf4++)
{ cout<<hrf4;
cout<<' ';
}
cout<<endl;
}
}
have fun and keep study hard guys :)
2 komentar:
makasih fachri cakep
sama" el :D
Posting Komentar