-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculator.c
More file actions
86 lines (85 loc) · 1.94 KB
/
Calculator.c
File metadata and controls
86 lines (85 loc) · 1.94 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <stdio.h>
void sum(int a,int b)
{
int sum = a+b;
printf (" The sum is : %d",sum);
}
void substract(int a,int b)
{
int sub = a-b;
printf (" The substracted value is : %d",sub);
}
void product(int a,int b)
{
int prod = a*b;
printf (" The product is : %d",prod);
}
void division(int a,int b)
{
int div = a/b;
printf (" The divided value is : %d",div);
}
int main ()
{
int a,b,operation;
start:
printf ("\n~~~~~~~~~~CALCULATOR~~~~~~~~~~\n");
printf ("\t Press 1 for Addition\n");
printf ("\t Press 2 for Substraction\n");
printf ("\t Press 3 foe Multiplicatiom\n");
printf ("\t Press 4 for Division\n");
printf ("\t press 5 to quit\n");
scanf("%d",&operation);
if( operation == 1)
{
printf(" ADDITION \n");
printf("Enter the first no. : ");
scanf("%d",&a);
printf("Enter the second no. : ");
scanf("%d",&b);
sum(a,b);
goto start;
}
else if(operation == 2)
{
printf(" SUBSTRACTION \n");
printf("Enter the first no. : ");
scanf("%d",&a);
printf("Enter the second no. : ");
scanf("%d",&b);
substract(a,b);
goto start;
}
else if (operation == 3)
{
printf(" multiplication \n");
printf("Enter the first no. : ");
scanf("%d",&a);
printf("Enter the second no. : ");
scanf("%d",&b);
product(a,b);
goto start;
}
else if (operation == 4)
{
printf(" DIVISION \n");
printf (" NOTE : enter the greater number first\n");
printf("Enter the first no. : ");
scanf("%d",&a);
printf("Enter the second no. : ");
scanf("%d",&b);
division(a,b);
goto start;
}
else if (operation == 5)
{
printf ("quitting the program");
goto end;
}
else
{
printf ("Invalid input");
}
end:
return 0;
}