Photobucket Photobucket Photobucket

Friday, December 2, 2011

Program C++ membuat Segitiga

Program 1 :
#include<iostream.h>
#include<conio.h>
main()
{
int i,j,k,n;
cout<<" Masukkan angka untuk gambar segitiga :";cin>>n;
cout<<endl;
for(i=n;i>=0;i--)
{
for(j=i;j>=0;j--)
{
cout<<" ";
}
for(k=0;k<=n-i;k++)
{
cout<<"*";
}
cout<<endl;
}
getch();
}

program setelah di compile :











Program 2 :

#include<iostream.h>
#include<conio.h>
main();
{
int v,a,b,c;
cout<<" Masukkan angka untuk gambar segitiga:";cin>>v;
cout<<endl;
for(a=0;a<=v;a++)
{
for(b=0;b<=a;b++)
{
cout<<" ";
}
for(c=0;c>=(a-v);c--)
{
cout<<"*";
}
cout<<endl;
}
getch();
}

Program setelah di compile :










Program 3 :

#include<iostream.h>
#include<conio.h>
main()
{
int v,a,b,c;
cout<<" Masukkan angka untuk gambar segitiga :";cin>>v;
cout<<endl;
for(a=1;a<=v;a++)
{
for(b=1;b<=a;b++)
{
cout<<"*";
}
cout<<endl;
}
getch();
}

program setelah di compile :











Semoga bermanfaat....
Arigatou Gozaimasu....

1 comment: