Senin, 26 November 2012
PERULANGAN PADA BAHASA C
#include <stdio.h>
#include <conio.h>
main (){
int matrik[2][4];
int i,u,e,z,pil,j,as;
char lagi;
char nama[] = "Laboratorium TI Gunadarma" ;
atas:
clrscr();
printf ("===============\n");
printf ("= PROGRAM AP3 =\n");
printf ("===============\n");
printf ("= 1. Bintang =\n");
printf ("= 2. Array =\n");
printf ("= 3. Matriks =\n");
printf ("= 4. Exit =\n");
printf ("===============\n");
printf ("\nMasukkan pilihan anda : ");
scanf ("%d",&pil);
switch (pil)
{
case 1:
clrscr();
printf ("Masukkan Jumlah Tingkat Bintang : ");
scanf ("%i",&z);
e=1;
for(u=1;u<=z;u++)
{
for (j=z-1;j>=u; j--)
{
printf(" ");
}
for (i=1;i<=e;i++)
{
delay(100);
printf ("*");
}
e=e+2;
printf ("\n");
}
printf("\n\nMasih mau lanjut ( y / n ) : ");
scanf("%s",&lagi);
getch();
if (lagi == 'y'){
goto atas;
}
else {
clrscr();
exit(1);
}
break;
case 2:
clrscr();
u=strlen(nama);
for(i=0; i<u; i++){
for(j=0; j<20;j++){
for(as=0; as<20; as++){
}
}
delay(100);
printf("%c",nama[i]);
}
printf("\n\nMasih mau lanjut ( y / n ) : ");
scanf("%s",&lagi);
getch();
if (lagi == 'y'){
goto atas;
}
else {
clrscr();
exit(1);
}
break;
case 3:
clrscr();
printf("Masukkan elemen Matriks :\n");
for (i=0; i<2; i++)
{
for (j=0; j<4; j++)
{
printf("Elemen [%d,%d] = ", i+1, j+1);
scanf("%d", &matrik[i][j]);
}
}
printf("\nIsi Matriks :\n\n");
for (i=0; i<2; i++)
{
for (j=0; j<4; j++)
{
printf("%5d", matrik[i][j]);
}
printf("\n");
}
printf("\n\nMasih mau lanjut ( y / n ) : ");
scanf("%s",&lagi);
getch();
if (lagi == 'y'){
goto atas;
}
else {
clrscr();
exit(1);
}
break;
case 4 :
exit(1);
break;
default :
printf("\nInput Salah !");
}
}
mau liat output? lihat disini.
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar