RSS

Calculator

#include <stdio.h>
#include <math.h>

main()

{
int a,b,c;
double hasil;
char yes;

cobalagi:
printf(“Program Calculator Sederhana : \n\n”);
printf(“\t 1. Penambahan \n”);
printf(“\t 2. Pengurangan \n”);
printf(“\t 3. Perkalian \n”);
printf(“\t 4. Pembagian \n”);
printf(“\t 5. Pangkat \n\n”);
printf(“Pilihan Anda : “);
scanf(“%d”,&a);
printf(“Masukkan bil 1 : “);
scanf(“%d”,&b);
printf(“Masukkan bil 2 : “);
scanf(“%d”,&c);

if(a==1){
hasil=b+c;
printf(“Hasil Operasinya : %0.0lf \n\n”,hasil);
goto link;
}else if(a==2){
hasil=b-c;
printf(“Hasil Operasinya : %0.0lf \n\n”,hasil);
goto link;
}else if(a==3){
hasil=b*c;
printf(“Hasil Operasinya : %0.0lf \n\n”,hasil);
goto link;
}else if(a==4){
hasil=b/c;
printf(“Hasil Operasinya : %0.0lf \n\n”,hasil);
goto link;
}else if(a==5){
hasil=pow(a,b);
printf(“Hasil Operasinya : %0.2lf \n\n”,hasil);
goto link;
}
else
{printf(“Fatal Eror!!!!!\n\n”);}

link:
printf(“Coba lagi? (Y/N) “,yes);
scanf(“%s”, &yes);
if (yes==’Y’)
{
goto cobalagi;
}
else{
printf (“Terimakasih”);
printf(“\n”);
}
}

 

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

 
%d blogger menyukai ini: