-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabc.cpp
More file actions
580 lines (520 loc) · 9.96 KB
/
abc.cpp
File metadata and controls
580 lines (520 loc) · 9.96 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
/******coded by rakesh kumar gupta
copyright reseved to rakesh kumar gupta
date 2december 2017 time 10:00to3:47******/
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<math.h>
#define v "vowel"
void sum(void);
void per(void);
void ctof(void);
void ftoc(void);
void tri(void);
void cheako_e(void);
void absulate(void);
void fact(void);
void power(void);
void pascii(void);
void arm(void);
void ptable(void);
void lcm(void);
void hcf(void);
void sqrt(void);
void chlarge(void);
void chtriangle(void);
void vowel(void);
void main()
{
int ch1,ch2;
char a[15];
gotoxy(30,1);
printf("enter your name\n");
gotoxy(31,2);
gets(a);
gotoxy(29,3);
printf("hello");
puts(a);
start:
while(2)
{
gotoxy(29,4);
printf("enter the given choise\n");
printf("1:simple programing\n2:Desison programing\t3:loop programing");
printf("\n4:other types of program\t5:Exit\t6clear screen");
scanf("%d",&ch1);
switch(ch1)
{
case 1:
while(3)
{
printf("\nenter your choise");
printf("\n1:sum of numbers");
printf("\n2:percentage of number");
printf("\n3:change farenhite to celcius");
printf("\n4:change celcius to farenhite");
printf("\n5:exit from sub menu");
printf("\n6:clear the screen");
scanf("%d",&ch2);
switch(ch2)
{ //start of switch sub
case 1:
sum();
break;
case 2:
per();
break;
case 3:
ftoc();
break;
case 4:
ctof();
break;
case 5:
goto start;
case 6:
clrscr();
default:
printf("\nenter choise does not exit please enter again");
}//end of swtich sub
}//end of while sub
//start of second case
case 2:
while(3)
{//start of while second sub
printf("\nenter your choise:");
printf("\n1:cheak for odd even");
printf("\n2:find abululte value");
printf("\n3:find squre root of number:");
printf("\n4:cheak validiti of triangle");
printf("\n5:exit from sum menu");
printf("\n6:clear screen");
scanf("%d",&ch2);
switch(ch2)
{//start of while second sub
case 1:
cheako_e();
break;
case 2:
absulate();
break;
case 3:
sqrt();
break;
case 4:
chtriangle();
break;
case 5:
goto start;
case 6:
clrscr();
default:
printf("enter choise does not exit please try again\n");
break;
}//closo of while second sub
}//close of while second sub
case 3:
while(3)
{ //start of while third sub
printf("enter the choise given below");
printf("\n1:find factorial");
printf("\n2:power fo number");
printf("\n3:armstrong number cheak");
printf("\n4:find lcm and hcf");
printf("\n5:exit from sub menu");
printf("\n6:clear screen");
scanf("%d",&ch2);
switch(ch2)
{//start of swtich third sub
case 1:
fact();
break;
case 2:
power();
break;
case 3:
arm();
break;
case 4:
lcm();
hcf();
break;
case 5:
goto start;
case 6:
clrscr();
default:
printf("choie does not exit please try again");
}//close of switch third sub
}//close of while third sub
case 4:
while(3)
{//start while four sub
printf("enter your choise given below");
printf("\n1:cheak vowel and consonant");
printf("\n2:print all ascii code");
printf("\n3:print table of number");
printf("\n4:cheak larger number among three");
printf("\n5:print trigonomenty value");
printf("\n6:exit from sub menu");
printf("\n7:clear screen");
scanf("%d",&ch2);
switch(ch2)
{//start of switch four sub
case 1:
vowel();
break;
case 2:
pascii();
break;
case 3:
ptable();
case 4:
chlarge();
break;
case 5:
tri();
break;
case 6:
goto start;
case 7:
clrscr();
default:
printf("choise does not exit please try again\n");
}//close of switch four sub
}//close while four sub
case 5:
exit(1);
break;
case 6:
clrscr();
break;
default:
printf("choise does not exit please try again\n");
break;
}//end of switch main
}//end of while main
}//end od main function
//start for function defining
void sum(void)
{
int a,i;
int b[20];
int sum=0;
char another;
clrscr();
do
{
printf("how many number you want to add");
scanf("%d",&a);
printf("enter the number which you want to add");
for(i=0;i<a;i++)
{
scanf("%d",&b[i]);
sum=sum+b[i];
}
printf("the sum of your entered number is %d",sum);
printf("wnat to add another number ('y'/'n')\n");
fflush(stdin);
scanf("%c",&another);
}while(another=='y');
getch();
}//first declarin
void per(void)
{
int a[20];
int b;
int sum=0,i;
char another;
clrscr();
float per;
do{
printf("how many number you want to find percentage\n");
scanf("%d",&b);
printf("enter the number which you want to find percentage");
for(i=0;i<b;i++)
{
scanf("%d",&a[i]);
sum=sum+a[i];
}
per=(sum*100)/(i*100);
printf("percentage is %f%",per);
printf("want to find more percentage ('y'/'n')");
fflush(stdin);
scanf("%c",&another);
}
while(another=='y');
getch();
}
//second declaired
void ftoc(void)
{
float celsius, fahrenheit;
printf("Please Enter the temperature in Fahrenheit: \n");
scanf("%f", &fahrenheit);
// Convert th temperature from fahrenheit to celsius
celsius = (fahrenheit - 32) * 5 / 9;
//celsius = 5 * (fahrenheit - 32) / 9;
//celsius = (fahrenheit - 32) * 0.55556;
printf("\n %.2f Fahrenheit = %.2f Celsius", fahrenheit, celsius);
getch();
}
//third declated
void ctof(void)
{
float celsius, fahrenheit;
printf("Please Enter the temperature in Fahrenheit: \n");
scanf("%f",&celsius);
// Convert th temperature from fahrenheit to celsius
fahrenheit=(celsius*9/5)+32;
//celsius = 5 * (fahrenheit - 32) / 9;
//celsius = (fahrenheit - 32) * 0.55556;
printf("\n%fcelsius=%f fahrenheit",celsius,fahrenheit);
getch();
}//fourth declared
void tri(void)
{
float a;
char t;
clrscr();
printf("enter the angle value");
scanf("%f",&a);
a=a*(3.142/180);
printf("enter's'for sin value ,'c' for cos value and 't'for tan value\n");
fflush(stdin);
scanf("%c",&t);
switch(t)
{
case 's':
printf("sin()value is %f",sin(a));
break;
case 'c':
printf("cos() value is %f",cos(a));
break;
case 't':
printf("tan() value is %f",tan(a));
break;
default:
printf("you entered wronmg choie");
break;
}
getch();
}//fifth declared
void cheako_e(void)
{
int a;
clrscr();
printf("enter a number to cheak odd and even\n");
scanf("%d",&a);
if(a%2==0)
printf("%d is even number ",a);
else
printf("%d is odd number",a);
getch();
}
void absulate(void)
{
int a;
clrscr();
printf("enter a number\n");
scanf("%d",&a);
printf("\n%d is absulate number",abs(a));
getch();
}
//sixth declared
void fact(void)
{
int f=1,num;
int i;
clrscr();
printf("enter a number");
scanf("%d",&num);
for(i=1;i<=num;i++)
{
f=f*i;
}
printf("%d",f);
getch();
}//seventh declared
void power(void)
{
int b,p;
clrscr();
printf("enter the base of number \n");
scanf("%d",&b);
printf("enter the power of number\n");
scanf("%d",&p);
printf("the %d^%d is %d",b,p,pow(b,p));
getch();
}//eights declared
void pascii(void)
{
int i;
printf("it print all asci code (enter to start)");
getch();
for(i=0;i<=255;i++)
printf("ascii value of %d=%c\t",i,i);
getch();
}
//ninth declared
void arm(void)
{
int number, sum = 0, rem = 0, cube = 0, temp;
printf ("enter a number");
scanf("%d",&number);
temp = number;
while (number != 0)
{
rem = number % 10;
cube = pow(rem, 3);
sum = sum + cube;
number = number / 10;
}
if (sum == temp)
printf ("The given no is armstrong ");
else
printf ("The given no is not a armstrong");
getch();
}
//tenth declared
void ptable(void)
{
int a,t;
int i;
clrscr();
printf("enter a number which you want to print table\n");
scanf("%d",&a);
for(i=1;i<=10;i++)
{
t=i*a;
printf("%d*%d=%d",i,a,t);
}
getch();
}
//eleventh declared
void hcf(void)
{
int i, num1, num2, min, hcf=1;
/* Input two numbers from user */
printf("Enter any two numbers to find HCF: ");
scanf("%d%d", &num1, &num2);
/* Find minimum between two numbers */
min = (num1<num2) ? num1 : num2;
for(i=1; i<=min; i++)
{
/* If i is factor of both number */
if(num1%i==0 && num2%i==0)
{
hcf = i;
}
}
printf("HCF of %d and %d = %d\n", num1, num2, hcf);
getch();
}
//twelve declared
void lcm(void)
{
int a,b;
int lcm;
clrscr();
printf("enter two number to find their lcm");
scanf("%d%d",&a,&b);
for(lcm=1;lcm<=a*b;lcm++)
{
if(lcm%a==0&&lcm%b==0)
break;
}
printf("lcm is %d",lcm);
getch();
} //thirteen declared
void sqrt(void)
{
float a;
clrscr();
printf("enter a number\n");
scanf("%f",&a);
a=sqrt(a);
printf("this is squre root of number%f",a);
getch();
} //fourteen declred
void chlarge(void)
{
int a,b,c;
int g;
clrscr();
printf("enter three number to cheak larger number ");
scanf("%d%d%d",&a,&b,&c);
if((a>b)&&(a>c))
g=a;
if((b>a)&&(b>c))
g=b;
else
g=c;
printf("largest number is %d",g);
getch();
} //fifteen declared
void chtriangle(void)
{
int a,b,c;
int g;
clrscr();
printf("enter the side of triangle to cheak it validity\n");
scanf("%d%d%d",&a,&b,&c);
if((a>b)&&(a>c))
{g=a;
if(g>b+c)
printf("triangle is valid");
else
printf("triangle is not valid");
}
if((b>c)&&(b>a))
{
g=b;
if(b>a+c)
printf("triangle is valid ");
else
printf("triangle is not valid");
}
else
{
g=c;
if(g<a+b)
printf("triangle is valid");
else
printf("triangle is not valid:");
}
getch();
} //sisteen declared
void vowel(void)
{
char a;
clrscr();
printf("enter a character to cheak vowel and cons\n");
scanf("%c",&a);
switch(a)
{
case 'a':
case 'A':
printf(v);
break;
case 'e':
case 'E':
printf(v);
break;
case 'i':
case 'I':
printf(v);
break;
case 'o':
case 'O':
printf(v);
break;
case 'u':
case 'U':
printf(v);
default:
printf("this is consonant");
break;
}
getch();
}