-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathcalci.c
44 lines (39 loc) · 916 Bytes
/
calci.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
#include <stdio.h>
int main()
{
{
int a,b;
char c;
// The user has to enter the first number
printf("Enter the first number: ");
// scan the input
scanf("%d",&a);
// The user has to enter the second number
printf("Enter the second number: ");
scanf("%d",&b);
//Enter the operation type
printf("Enter the operator: ");
scanf(" %c",&c);
switch(c)
{
case '+':
printf("The sum is %d",(a+b));
break;
case '-':
printf("The difference is %d",(a-b));
break;
case '*':
printf("The product is %d",(a*b));
break;
case '/':
printf("The quotient is %d",(a/b));
break;
case '%':
printf("The quotient is %d",(a%b));
break;
default:
printf("Invalid operator");
}
return 0;
}
}