-
Notifications
You must be signed in to change notification settings - Fork 1
/
SimpleCalculatorFunction.c
63 lines (63 loc) · 1.05 KB
/
SimpleCalculatorFunction.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
#include<stdio.h>
float sum(int x,int y);
float diff(int x,int y);
float product(int x,int y);
float remainder(int x,int y);
float modulo(int x, int y);
int main()
{
int a,b;
char c;
printf("Enter any 2 no=");
scanf("%d%d",&a,&b);
printf("Enter the operator=");
scanf("%c",&c);
switch(c)
case +: printf("Addition");
sum(a,b);
break;
case -: printf("Subtraction");
diff(a,b);
break;
case *: printf("Product");
product(a,b);
break;
case /: printf("Remainder a/b");
remainder(a,b);
break;
case %: printf("Quotient a/b");
modulo(a,b);
break;
default: printf("Invalid");
return(0);
}
float sum(int x,int y)
{
float d;
d=x+y;
printf("Sum=%f",d);
}
float diff(int x,int y)
{
float d;
d=x-y;
printf("Diff=%f",d);
}
float product(int x,int y)
{
float d;
d=x*y;
printf("Product=%f",d);
}
float remainder(int x,int y)
{
float d;
d=x/y;
printf("Remainder=%f",d);
}
float modulo(int x,int y)
{
float d;
d=x%y;
printf("Quotient=%f",d);
}