menu di bahasa c

saya mau sharing tentang bahasa pemograman c,yang kebetulan ini untuk ujian di kampus saya

ini coding nya

#include
#include
#include
void main()
{
char pilih;
int pilihk, sisi;
float jari;
menu:
clrscr();
printf("\n");
printf("<<<>>>\n");
printf("\n");
printf("A. Menghitung Kubus\n");
printf("B. Menghitung Luas Lingkaran\n");
printf("C. Exit\n");
printf("\n");
printf("Pilih Nomor (A-C)?");
scanf("%c",&pilih);
{
switch(toupper(pilih))
{
case 'A' :
printf("1. Volume kubus\n");
printf("2. Luas sisi kubus\n");
printf("\n");
printf("Pilih nomor(1-2)?");
scanf("%d",&pilihk);
printf("\n");
printf("Panjang sisi kubus?");
scanf("%d",&sisi);
switch(pilihk);
{
case 1 :
printf("Volume kubus=%d\n",sisi*sisi*sisi);
getch();
goto menu;
case 2 :
printf("Luas sisi kubus=%d\n",6*sisi*sisi);
getch();
goto menu;
}
case 'B' :
printf("Jari-jari lingkaran?");
scanf("%f",&jari);
printf("Luas lingkaran=%f\n",3.14*jari*jari);
getch();
goto menu;
case 'C' :
printf("exit");
goto end;
default:
printf("salah");
goto menu;
}
}
end:
}

untuk output nya kira kira akan seperti ini




saya mengucapkan terima kasih kepada saudara Febry phetot untuk coding nya, lumayan buat aya belajar ujian. hahaha




This entry was posted on Kamis, 24 Maret 2011. You can follow any responses to this entry through the RSS 2.0. You can leave a response.

Leave a Reply