Created
March 22, 2017 16:58
-
-
Save MohammedRashad/88ff29b95c81059a18988b7e82a4d3a3 to your computer and use it in GitHub Desktop.
Calculator Program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(int argc, char** argv) { | |
double x, y, z, n; | |
char a; | |
printf("===== Calculator App =====\n\n"); | |
printf("Choose Operation : \n\n"); | |
printf("1-Add"); | |
printf("2-Subtract"); | |
printf("3-Multiply"); | |
printf("4-Divide"); | |
printf("\n\nYour Choice >> "); | |
scanf("%d", &x); | |
switch(x) { | |
case 1: | |
printf("Add 2 numbers to Add :\n"); | |
scanf("%lf", &y); | |
scanf("%lf", &z); | |
n = y + z; | |
printf("Result : %d", n); | |
break; | |
case 2: | |
printf("Add 2 numbers to Subtract :\n"); | |
scanf("%lf", &y); | |
scanf("%lf", &z); | |
n = y - z; | |
printf("Result : %lf", n); | |
break; | |
case 3: | |
printf("Add 2 numbers to Multiply :\n"); | |
scanf("%lf", &y); | |
scanf("%lf", &z); | |
n = y * z; | |
printf("Result : %lf", n); | |
break; | |
case 4: | |
printf("Add 2 numbers to Divide :\n"); | |
scanf("%lf", &y); | |
scanf("%lf", &z); | |
n = y / z; | |
printf("Result : %lf", n); | |
break; | |
default: | |
printf("Invalid"); | |
break; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment