#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
int main () {
char c='1';
int p,l;
while (c!='5'){
system("cls");
printf("******************************\n");
printf("********Menghitung Luas*******\n");
printf("******************************\n");
printf("* 1. Persegi Panjang \n");
printf("* 2. Persegi \n");
printf("* 3. Lingkaran \n");
printf("* 4. Segitiga \n");
printf("* 5. selesai \n");
printf("******************************\n");
printf("* Pilih Salah Satu! ");
do{
c= getch ();
if(c>='1'&&c<='5') printf("%c",c);
}
while(c<'1'||c>'5');
printf(" *\n");
printf("******************************\n\n\n");
switch(c){
case '1': printf("Panjang : "); scanf("%d",&p);
printf("lebar : "); scanf("%d",&l);
printf("Luas : %d\n\n",p*l);
break;
case '2': printf("Panjang sisi: "); scanf("%d",&p);
printf("Luas : %d\n\n",p*p);
break;
case '3': printf("Diameter: "); scanf("%d",&p);
printf("Luas : %d\n\n",(float)22/7*p*p/4);
break;
case '4': printf("Alas : "); scanf("%d",&p);
printf("lTinggi : "); scanf("%d",&l);
printf("Luas : %d",(float)p*l/2);
break;
}
getch();
}
printf("\n\n");
system("pause");
return(0);
}
0 komentar:
Posting Komentar