listing.y :
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
main(){
int a,b;
for (a=5;a>0;a--){
for (b=1;b<=a;b++)
{
cout<<b<<" ";
}
cout<<endl;
}
getch();
}
Looping Segitiga Angka Terbalik :
Listing.y :
#include <iostream.h>
#include <stdio.h>
#include <conio.h>
main(){
int a,b;
for (a=1;a<=10;a++)
{
cout<<a<<" ";
for (b=a+1;b<=10;b++)
{
cout<<b<<" ";
}
cout<<endl;
}
getch();
}
Looping Segitiga Rata Kanan
Listing.y :
#include <iostream.h>
#include <conio.h>
void main()
{
int i,j,k;
for(i=0;i<=10;i++)
{
for(j=10;j>=i;j--)
{
cout<<" ";
}
for(k=0;k<=i;k++)
{
cout<<"*";
}
cout<<"\n";
}
getch();
}
Tidak ada komentar:
Posting Komentar