-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu driven programs
More file actions
141 lines (133 loc) · 2.47 KB
/
menu driven programs
File metadata and controls
141 lines (133 loc) · 2.47 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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
program 1
#include<stdio.h>
#include<math.h>
int main()
{
int n,a;
printf("1.Factorial of a no\n");
printf("2.Check even or odd\n");
printf("3.Area of circle\n");
printf("4.Sum of first N natural no\n");
printf("5.Exit\n");
printf("\nSelect an option:");
scanf("%d",&n);
switch(n)
{
case 1 :
int m=1;
printf("Enter a no");
scanf("%d",&a);
while(a)
{
m=m*a;
a--;
}
printf("%d",m);
printf("\n");
break;
case 2 :
int h;
printf("Enter a no");
scanf("%d",&h);
h&1?printf("Odd"):printf("Even");
printf("\n");
break;
case 3 :
float u;
printf("Enter radius");
scanf("%d",&a);
u= 3.14*a*a;
printf("Area of circle is %f",u);
printf("\n");
break;
case 4 :
int r=0;
printf("Enter a no");
scanf("%d",&a);
while(a)
{
r=r+a;
a--;
}
printf("%d",r);
printf("\n");
break;
case 5 :
break;
default :
printf("Invalid entry\n\n");
}
return 0;
}
program 2
#include<stdio.h>
int main()
{
while(1)
{
int a;
printf("1.LCM of two nos\n");
printf("2.Sum of digits of no\n");
printf("3.Volume of cuboid\n");
printf("4.Prime no check\n");
printf("5.Exit\n");
printf("\nSelect an option:");
scanf("%d",&a);
switch(a)
{
case 1 :
int m,n,c;
printf("Enter two nos");
scanf("%d %d",&m,&n);
for((c=m>n?m:n);c<=m*n;c++)
{
if(c%m==0 && c%n==0)
{
printf("%d",c);
break;
}
}
printf("\n");
break;
case 2 :
int f=0,h;
printf("Enter a no");
scanf("%d",&h);
while(h)
{
f= f+h%10;
h/=10;
}
printf("Sum of digits is %d",f);
break;
case 3:
int v,k,j,d;
printf("Enter three side lengths");
scanf("%d %d %d",&k,&j,&d);
v=k*j*d;
printf("Volume of cuboid is %d",v);
printf("\n");
break;
case 4:
int t,e;
printf("Enter no");
scanf("%d",&t);
for(e=2;e<=t-1;e++)
{
if(t%e==0)
{
printf("Not a prime no");
break;
}
}
if(e==t)
printf("Prime no");
printf("\n");
case 5 :
break;
default :
printf("\nInvalid entry");
}
}
return 0;
}