Pada posting kali ini saya akan sedikit sharing tentang contoh program segitiga dengan menggunakan bahasa pemograman C++ !
coba lihat tampilan program :
Gambar 1 :
#include <iostream>
using namespace std;
int main ()
{
int a;
cout<<"|| Program Looping Segitiga siku-siku ||"<<endl;
cout<<"|| Created by : Dragoen.blogspot.com ||"<<endl<<endl;
cout<<" Masukkan Jumlah pengulangan : ";
cin>>a;
cout<<"----------------------------------------"<<endl<<endl;
for(int f=a;f>=1;f--)
{
cout<<endl;
for (int g=f;g<=a;g++)
{
cout<<" # ";
}
}
cout<<"\n"<<endl<<endl;
cout<<"----------------------------------------"<<endl<<endl;
system ("pause");
}
Gambar 2 :
#include <iostream>
using namespace std;
int main ()
{
int a;
cout<<"|| Program Looping Segitiga siku-siku ||"<<endl;
cout<<"|| Created by : Dragoen.blogspot.com ||"<<endl<<endl;
cout<<" Masukkan Jumlah pengulangan : ";
cin>>a;
cout<<"----------------------------------------"<<endl<<endl;
for(int f=a;f>=1;f--)
{
cout<<endl;
for (int g=f;g<=a;g++)
{
cout<<" # ";
}
}
cout<<"\n"<<endl<<endl;
cout<<"----------------------------------------"<<endl<<endl;
system ("pause");
}
Semoga bermanfaat !!
Tidak ada komentar:
Posting Komentar