Program Calculator Sederhana Dengan Bahasa C

Posted on Updated on


#include<stdio.h>

#include <conio.h>
void main()
{
float x,y,tambah,kurang,kali,bagi;
int a,b,sisabagi;

printf("\tPROGRAM CALCULATOR\n");
printf("Input bilangan ke-1: "); /*proses untuk memasukan bilangan*/
scanf("%f",&x);
printf("Input bilangan ke-2: ");
scanf("%f",&y);
a=x; /*a diberi nilai x untuk nilai int*/
b=y; /*b diberi nilai y untuk nilai int*/
tambah=x+y; /*rumus/proses pertambahan*/
kurang=x-y; /*rumus/proses pengurangan*/
kali=x*y; /*rumus/proses perkalian*/
bagi=x/y; /*rumus/proses pembagian*/
sisabagi=a%b; /*rumus/proses sisabagi*/

printf("\nHasil %.1f + %.1f : %.1f",x,y,tambah);
printf("\nHasil %.1f - %.1f : %.1f",x,y,kurang);
printf("\nHasil %.1f X %.1f : %.1f",x,y,kali);
printf("\nHasil %.1f : %.1f : %.2f",x,y,bagi);
printf("\nHasil %.i mod %.i : %i",a,b,sisabagi);
getch();
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s