forked from crazy98/C---languge-challange
-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculator.c
62 lines (33 loc) · 883 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Write a simple menu driven calculator to perform (+ - / *) operations. (The program must display a menu to select the desired operator.)
#include <stdio.h>
#include <stdlib.h>
int main()
{
int num1,num2;
char op;
printf("Enter the number 01:");
scanf("%d",&num1);
printf("Enter the number 02:");
scanf("%d",&num2);
printf("****************\n + for addition \n - for substraction \n / for division \n* for multiplication \n\n *****************");
printf("\nEnter the operator");
scanf(" %c",&op);
switch(op)
{
case '+':
printf("The sum is:%d",(num1+num2));
break;
case '-':
printf("The difference is %d",(num1-num2));
break;
case '*':
printf("The product is %d",(num1*num2));
break;
case '/':
printf("The division is %d",(num1/num2));
break;
default:
printf("Enter a valid operator");
}
return 0;
}