Saturday, February 04, 2012

Kalkulator "Switch" (Borland C++)

 
/*
##################################
# Kalkulator Sederhana (Switch)
##################################
Ket :
a = Nilai input pertama
b = Nilai input kedua
c = Hasil nilai input
menu = Pemilihan case 1-4

Hasil Output :
Menu
Input Nilai Pertama
Input Nilai Kedua
Hasil
*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int menu,a,b,c;
printf("==================================\n");
printf("Kalkulator Sederhana\n");
printf("==================================\n");
printf("1. Perkali\n");
printf("2. Pembagi\n");
printf("3. Penjumlahan\n");
printf("4. Pengurangan\n");
printf("==================================\n");
printf("Pilih Menu = ");scanf("%d",&menu);
switch(menu)
{
case 1:
printf("Angka Pertama = ");scanf("%d",&a);
printf("Angka Kedua = ");scanf("%d",&b);
c=a*b;
printf("==================================\n");
printf("Hasil = %d",c);
printf("\n==================================\n");
break;
case 2:
printf("Angka Pertama = ");scanf("%d",&a);
printf("Angka Kedua = ");scanf("%d",&b);
c=a/b;
printf("==================================\n");
printf("Hasil = %d",c);
printf("\n==================================\n");
break;
case 3:
printf("Angka Pertama = ");scanf("%d",&a);
printf("Angka Kedua = ");scanf("%d",&b);
c=a+b;
printf("==================================\n");
printf("Hasil = %d",c);
printf("\n==================================\n");
break;
case 4:
printf("Angka Pertama = ");scanf("%d",&a);
printf("Angka Kedua = ");scanf("%d",&b);
c=a-b;
printf("==================================\n");
printf("Hasil = %d",c);
printf("\n==================================\n");
break;
default:
printf("==================================\n");
printf("Menu Tidak Dapat Di Temukan\n");
printf("\n==================================\n");
}
getch();
}

I am a fan of technology and i love coffee. I’m also interested in web programming and networking. below there are some accounts you can follow to contact me.