-
Notifications
You must be signed in to change notification settings - Fork 16
/
9.c
58 lines (50 loc) · 1.08 KB
/
9.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
#include <stdio.h>
int sum(int a, int b)
{
return a + b;
}
int difference(int a, int b)
{
return a - b;
}
int product(int a, int b)
{
return a * b;
}
int division(int a, int b)
{
return a / b;
}
int main()
{
int a, b;
char operation;
printf("Enter first number: ");
scanf("%d", &a);
printf("Enter second number: ");
scanf("%d", &b);
printf("Enter one of the followings: ");
printf("\n(a) Sum of the numbers ");
printf("\n(b) Difference of the numbers ");
printf("\n(c) Product of the numbers ");
printf("\n(d) Division of the numbers ");
printf("\n");
scanf(" %c", &operation);
switch (operation)
{
case 'a':
printf("Result -> %d\n", sum(a, b));
break;
case 'b':
printf("Result -> %d\n", difference(a, b));
break;
case 'c':
printf("Result -> %d\n", product(a, b));
break;
case 'd':
printf("Result -> %d\n", division(a, b));
break;
default:
printf("Invalid operation\n");
}
}