![Page 1: Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");](https://reader036.vdocuments.us/reader036/viewer/2022062308/56649f4f5503460f94c706a2/html5/thumbnails/1.jpg)
Example #include<stdio.h> #include<conio.h> void main() {
int a,b,c,n;clrscr();printf("\nEnter the value of a,b:");scanf("%d%d",&a,&b);printf("\nMENU");printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");printf("\nEnter the choice:");scanf("%d",&n);
![Page 2: Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");](https://reader036.vdocuments.us/reader036/viewer/2022062308/56649f4f5503460f94c706a2/html5/thumbnails/2.jpg)
switch(n){ case 1:
c=a+b;printf("\nThe result of Addition is:%d",c);break;
case 2:c=a-b;printf("\nThe result of Subtraction is:%d",c);break;
![Page 3: Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");](https://reader036.vdocuments.us/reader036/viewer/2022062308/56649f4f5503460f94c706a2/html5/thumbnails/3.jpg)
case 3:c=a*b;printf("\nThe result of Multiplication is:%d",c);break;
case 0:exit(0);break;
}getch();
}
![Page 4: Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");](https://reader036.vdocuments.us/reader036/viewer/2022062308/56649f4f5503460f94c706a2/html5/thumbnails/4.jpg)
Output
Enter the value of a,b:56MENU1.ADD2.SUB3.MULTIPLY0.EXITEnter the choice:1The result of Addition is:11
![Page 5: Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");](https://reader036.vdocuments.us/reader036/viewer/2022062308/56649f4f5503460f94c706a2/html5/thumbnails/5.jpg)
Finding Armstrong No#include<stdio.h>#include<conio.h>void main(){ int r=0,sum=0,n,a; printf("\nEnter the number:"); scanf("%d",&n); a=n;
while(n>0){
r=n%10;sum=sum+r*r*r;n=n/10;
}
![Page 6: Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");](https://reader036.vdocuments.us/reader036/viewer/2022062308/56649f4f5503460f94c706a2/html5/thumbnails/6.jpg)
if(a==sum){ printf("\nIt is an armstrong number");}else{ printf("\nIt is not an armstrong number");}
getch();}
![Page 7: Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");](https://reader036.vdocuments.us/reader036/viewer/2022062308/56649f4f5503460f94c706a2/html5/thumbnails/7.jpg)
Output
Enter the number:153It is an armstrong number
![Page 8: Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");](https://reader036.vdocuments.us/reader036/viewer/2022062308/56649f4f5503460f94c706a2/html5/thumbnails/8.jpg)
Sum of the Digits#include<stdio.h>#include<conio.h>void main(){ int r=0,sum=0,n; printf("\nEnter the no:"); scanf("%d",&n); while(n>0) { r=n%10;
![Page 9: Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");](https://reader036.vdocuments.us/reader036/viewer/2022062308/56649f4f5503460f94c706a2/html5/thumbnails/9.jpg)
sum=sum+r; n=n/10; } printf("sum of the digits is:%d",sum);}
![Page 10: Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");](https://reader036.vdocuments.us/reader036/viewer/2022062308/56649f4f5503460f94c706a2/html5/thumbnails/10.jpg)
Output
Enter the no:156sum of the digits is:12
![Page 11: Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");](https://reader036.vdocuments.us/reader036/viewer/2022062308/56649f4f5503460f94c706a2/html5/thumbnails/11.jpg)
Reverse of a number
#include<stdio.h>#include<conio.h>void main(){ int r=0,sum=0,n; printf("\nEnter the no:"); scanf("%d",&n); while(n>0)
![Page 12: Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");](https://reader036.vdocuments.us/reader036/viewer/2022062308/56649f4f5503460f94c706a2/html5/thumbnails/12.jpg)
{ r=n%10; sum=sum*10+r; n=n/10;
} printf("Reverse of the number is:%d",sum); getch();}
![Page 13: Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");](https://reader036.vdocuments.us/reader036/viewer/2022062308/56649f4f5503460f94c706a2/html5/thumbnails/13.jpg)
Output
Enter the no:567Reverse of the number is:765
![Page 14: Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");](https://reader036.vdocuments.us/reader036/viewer/2022062308/56649f4f5503460f94c706a2/html5/thumbnails/14.jpg)
Fibonacci Series
#include<stdio.h>#include<conio.h>void main(){int f=0,f1=-1,f2=1,n,i;printf("\nEnter the number:");scanf("%d",&n);
![Page 15: Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");](https://reader036.vdocuments.us/reader036/viewer/2022062308/56649f4f5503460f94c706a2/html5/thumbnails/15.jpg)
while(f<n){ f=f1+f2;
f1=f2; f2=f;
printf("\t%d",f);}
getch();}
![Page 16: Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");](https://reader036.vdocuments.us/reader036/viewer/2022062308/56649f4f5503460f94c706a2/html5/thumbnails/16.jpg)
Output
Enter the number:5 0 1 1 2 3 5
![Page 17: Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");](https://reader036.vdocuments.us/reader036/viewer/2022062308/56649f4f5503460f94c706a2/html5/thumbnails/17.jpg)
Swapping #include<stdio.h>#include <conio.h>void main ( ){int a,b,c;clrscr( );printf(" \nEnter the value of a:");scanf("%d",&a);printf(" \nEnter the value of b:");scanf("%d",&b);c=a;a=b;b=c;
![Page 18: Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");](https://reader036.vdocuments.us/reader036/viewer/2022062308/56649f4f5503460f94c706a2/html5/thumbnails/18.jpg)
printf(" \nThe value of a is:%d",a);printf(" \nThe value of b is:%d",b);getch( );}
Output:Enter the value of a:5Enter the value of b:4
The value of a is:4The value of b is:5
![Page 19: Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");](https://reader036.vdocuments.us/reader036/viewer/2022062308/56649f4f5503460f94c706a2/html5/thumbnails/19.jpg)
Swapping without using third variable
#include<stdio.h>#include <conio.h>void main ( ){int a,b;clrscr( );printf(" \nEnter the value of a:");scanf("%d",&a);printf(" \nEnter the value of b:");scanf("%d",&b);
![Page 20: Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");](https://reader036.vdocuments.us/reader036/viewer/2022062308/56649f4f5503460f94c706a2/html5/thumbnails/20.jpg)
a=a+b;b=a-b;a=a-b;printf(" \nThe value of a is:%d",a);printf(" \nThe value of b is:%d",b);getch( );}
Output:Enter the value of a:5Enter the value of b:6
The value of a is:6The value of b is:5
![Page 21: Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");](https://reader036.vdocuments.us/reader036/viewer/2022062308/56649f4f5503460f94c706a2/html5/thumbnails/21.jpg)
Quadratic Equation#include<stdio.h>#include <conio.h>#include<math.h>void main ( ){int a,b,c,d,r1,r2;clrscr( );printf(" \nEnter the value of a:");scanf("%d",&a);printf(" \nEnter the value of b:");scanf("%d",&b);printf(" \nEnter the value of c:");scanf("%d",&c);d=b*b-4*a*c;
![Page 22: Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");](https://reader036.vdocuments.us/reader036/viewer/2022062308/56649f4f5503460f94c706a2/html5/thumbnails/22.jpg)
if(d>=0){
r1=(-b+sqrt(d))/(2*a);r2=(-b-sqrt(d))/(2*a);
printf(" \nThe roots are %d,%d",r1,r2);}else{ printf(" \nThe roots are imaginary");}getch( );}
![Page 23: Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");](https://reader036.vdocuments.us/reader036/viewer/2022062308/56649f4f5503460f94c706a2/html5/thumbnails/23.jpg)
Output
Enter the value of a:4
Enter the value of b:5
Enter the value of c:6
The roots are imaginary