-
Notifications
You must be signed in to change notification settings - Fork 1
/
calc.c
65 lines (58 loc) · 1.9 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include<stdio.h>
int main(){
int num1,num2,option;
do
{
printf("\nChoose your option\n");
printf("1.Addition\n2.Substraction\n3.Multiplication\n4.Division\n5.Exit\n");
scanf("%d",&option);
if(option==5)
{
break;
}
switch(option)
{
case 1:
printf("Enter the first Integer\n");
scanf("%d",&num1);
printf("Enter the second Integer\n");
scanf("%d",&num2);
printf("The Addition of %d and %d is: %d\n",num1,num2,num1+num2);
break;
case 2:
printf("Enter the first Integer\n");
scanf("%d",&num1);
printf("Enter the second Integer\n");
scanf("%d",&num2);
printf("The Substraction of %d and %d is: %d\n",num1,num2,num1-num2);
break;
case 3:
printf("Enter the first Integer\n");
scanf("%d",&num1);
printf("Enter the second Integer\n");
scanf("%d",&num2);
printf("The Multiplication of %d and %d is: %d\n",num1,num2,num1*num2);
break;
case 4:
printf("Enter the first Integer\n");
scanf("%d",&num1);
printf("Enter the second Integer\n");
scanf("%d",&num2);
if(num2==0)
{
printf("Error\n");
}
else
{
printf("The Division of %d and %d is : %d\n",num1,num2,num1/num2);
}
break;
case 5:
break;
default:
printf("Invalid option\n");
break;
}
}while(option!=5);
return 0;
}