-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmany programs using Functions;
120 lines (113 loc) · 2.25 KB
/
many programs using Functions;
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include <stdio.h>
int add(int,int);
int sub(int,int);
int mul(int,int);
int divi(int,int);
int fac(int);
int rev(int);
int main()
{
int a,b,c;
char cho;
printf("Enter your choice a-Addition s-Substraction m-Multiplication d-Division f-Factorial r-Reverse_a_number \n");
scanf("%c",&cho);
switch (cho)
{
case 'a':
printf("Addition\n");
printf("Enter the first value:\n");
scanf("%d",&a);
printf("Enter the second value:\n");
scanf("%d",&b);
c = add(a,b);
break;
case 's':
printf("Substraction\n");
printf("Enter the first value:\n");
scanf("%d",&a);
printf("Enter the second value:\n");
scanf("%d",&b);
c = sub(a,b);
break;
case 'm':
printf("Multiplication\n");
printf("Enter the first value:\n");
scanf("%d",&a);
printf("Enter the second value:\n");
scanf("%d",&b);
c = mul(a,b);
break;
case 'd':
printf("Division\n");
printf("Enter the first value:\n");
scanf("%d",&a);
printf("Enter the second value:\n");
scanf("%d",&b);
c = divi(a,b);
break;
case 'f':
printf("Factorial\n");
printf("Enter the value:\n");
scanf("%d",&a);
c = fac(a);
break;
case 'r':
printf("Reverse_a_number\n");
printf("Enter the number:\n");
scanf("%d",&a);
c = rev(a);
break;
default:
printf("Wrong Input\n");
}
}
int add(int x,int y)
{
int z;
z = x+y;
printf("The Addition is %d",z);
return(z);
}
int sub(int x,int y)
{
int z;
z = x-y;
printf("The Substraction is %d",z);
return(z);
}
int mul(int x,int y)
{
int z;
z = x*y;
printf("The Multiplication is %d",z);
return(z);
}
int divi(int x,int y)
{
int z;
z = x/y;
printf("The Division is %d",z);
return(z);
}
int fac(int x)
{
int i;
int z = 1;
for(i=1; i<=x; i++)
{
z = z*i;
}
printf("The Factorial is %d",z);
return(z);
}
int rev(int x)
{
int r,s=0;
for (x; x>0; )
{
r=x%10;
s=s*10+r;
x=x/10;
}
printf("The Reverse Number is %d",s);
}