[C++] Program Membuat Segitiga Siku-siku Kiri Atas dengan Looping While (Borland C++)
Input Program (Source Code)
#include <iostream.h>
#include <conio.h>
main()
{
int i,n,j;
i=1;
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
cout<<endl;
cout<<"PROGRAM MEMBUAT SEGITIGA SIKU-SIKU KIRI ATAS";
cout<<endl;
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
cout<<endl<<endl;
cout<<"Banyak baris: ";cin>>n;
cout<<endl;
while(i<=n)
{
cout<<i<<". ";
j=n;
while(j>=i)
{
cout<<"*";
j--;
}
cout<<endl;
i++;
}
getch();
}
#include <conio.h>
main()
{
int i,n,j;
i=1;
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
cout<<endl;
cout<<"PROGRAM MEMBUAT SEGITIGA SIKU-SIKU KIRI ATAS";
cout<<endl;
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
cout<<endl<<endl;
cout<<"Banyak baris: ";cin>>n;
cout<<endl;
while(i<=n)
{
cout<<i<<". ";
j=n;
while(j>=i)
{
cout<<"*";
j--;
}
cout<<endl;
i++;
}
getch();
}
Output Program
Algoritma Program
1. Input banyak baris (n)
2. Gunakan looping for untuk membentuk segitiga siku-siku kiri atas
3. i untuk looping penomoran dan j untuk looping *
Komentar
Posting Komentar