-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalc.c
45 lines (35 loc) · 990 Bytes
/
calc.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
40
41
42
43
44
45
#include<stdio.h>
int main() {
int a,b,c;
float s;
char o;
printf("\t\t\t\t\t\t calcultor\n\n\n\n");
printf("please enter your choice :(+ for addition ) (- for substration) (* for multiplication) (/ for division):");
scanf("%c",&o);
printf("Enter the number a:");
scanf("%d",&a);
printf("Enter the number b:");
scanf("%d",&b);
if(o=='+'){
s = a+b;
printf("the answer of addition is: %f",s);
}
else if(o=='-'){
s = a-b;
printf("the answer of subsctration is: %f",s);
}
else if(o=='*'){
s = a*b;
printf("the answer of multiplication is: %f",s);
}
else if(o=='/'){
if(b=o){
printf("divisor can't be zero");
}
s = a/b;
printf("the answer of division is: %d",s);
}
else {
printf("you enter wrong inputs");
}
}