Selasa, 10 April 2012

Contoh Program Perulangan C++


#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
int i,j,k,l;
cout<<"masukkan angka:"; cin >> i;
for(j= 1; j<= i; j++)
{
for(k=i; k>j; k--)
{
cout<< " ";
}
for (l=1; l<=j; l++)
{
If(l%2)
cout <<l<<"a";
else
cout<<l<<"b";
}
cout << " " << endl;
}
getch ();
}

outputnya :


Tidak ada komentar:

Posting Komentar