a. Mencetak Kata ( K I G E C A )
#include
void main ()
{
char huruf;
for (huruf='K'; huruf>='A'; huruf-=2)
{
cout<< huruf <<" ";
}
return;
}
b. Mencetak Angka
10 8 6
4 2
0
#include
void main ()
{
int a=10;
for (int i=1; i<=6; i++)
{
for (int j=i; j<=3; j++)
{
cout<< a <<" ";
a-=2;
}
cout<
return;
}
c. Mencetak
0 0 0 1
0 0 2 0
0 3 0 0
4 0 0 0
#include
#include
void main( )
{
int a,b,c;
clrscr ( );
c=4;
{
for(a=1;a<=4;a++)
{
for(b=1;b<=4;b++)
{
if (b==c)
cout< else
cout<<0<<" ";
}
c=c-1;
cout<
}
}

Tidak ada komentar:
Posting Komentar