Contoh 1 :
#include
#include
main()
{
int i,j,n;
clrscr();
printf(“Masukkan n : “);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{for (j=n;j>=1;j–)
{printf (“%d”,j);
}
printf (“\n”);
}
getche ();
}
#include
#include
main()
{
int i,j,n;
clrscr();
printf(“Masukkan n : “);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{for (j=n;j>=1;j–)
{printf (“%d”,j);
}
printf (“\n”);
}
getche ();
}
Contoh 2 :
#include
#include
main()
{
int i,j,n;
clrscr();
printf(“Masukkan n : “);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{for (j=1;j<=i;j++)
printf (“%d”,i);
printf (“\n”);
}
getche ();
}
#include
#include
main()
{
int i,j,n;
clrscr();
printf(“Masukkan n : “);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{for (j=1;j<=i;j++)
printf (“%d”,i);
printf (“\n”);
}
getche ();
}
Tidak ada komentar:
Posting Komentar