Program Menampilkan Belah Ketupat - Perulangan Do while / Looping C/C++
#include <stdio.h>
int main ()
{
int n, i, j, s;
printf ("Program membuat jajar genjang\n");
printf ("Masukan jumlah kolom = ");
scanf ("%d",&n);
for (i = 1; i <= n; i++)
{
for (j = 1; j <= n - i; j++)
{
printf (" ");
}
for (s = 1; s <= i; s++)
{
printf ("%d",s);
}
for (s = i - 1; s >= 1; s--)
{
printf ("%d",s);
}
printf ("\n");
}
n = n - 1;
for (i = 1; i <= n; i++)
{
for (j = 1; j <= i; j++)
{
printf (" ");
}
for (s = 1; s <= n - i + 1; s++)
{
printf ("%d",s);
}
for (s = n - i; s >= 1; s--)
{
printf ("%d",s);
}
printf ("\n");
}
return 0;
}
Hasil running
0 Response to "Program Menampilkan Belah Ketupat - Perulangan Do while / Looping C/C++"
Post a Comment