-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculator.c
39 lines (39 loc) · 768 Bytes
/
calculator.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include<stdio.h>
int main() {
double num1;
double num2;
int choice;
double add;
double sub;
double product;
double div;
printf("welcome to the calculator");
printf("input num1: ");
scanf("%f", &num1);
printf("input num2: ");
scanf("%f", &num2);
printf("what operation do you want to perform/n");
printf("enter/n");
printf("1-addition/n");
printf("2-subraction/n");
printf("3-multiplication/n");
printf("4-subraction/n");
scanf("%d",&choice);
if (choice=1) {
add=num1+num2;
printf("addition=%f",add);
}
else if (choice=2) {
sub=num1-num2;
printf("subraction=%f",sub);
}
else if(choice=3) {
product=num1*num2;
printf("multiplication=%f",product);
}
else if(choice=4) {
div=num1/num2;
printf("division=%f",div);
}
return 0;
}