C program find the GCD of the 2 numbers using functions

/*WAP to find the GCD of the 2 numbers using functions*/ #include<stdio.h> void main() { int gcd(int,int); int m,n; clrscr(); printf(“Input 2 Numbers-\n”); scanf(“%d%d”,&m,&n); printf(“GCD of %d and %d is %d”,m,n,gcd(m,n)); getch(); } int gcd(int x, int y) { while(x!=y) { if(x>y) x=x-y; else if(y>x) y=y-x; } return(x); } Output Input 2 Numbers- 12 24 … Read moreC program find the GCD of the 2 numbers using functions

Detect Armstrong number in 3 digits from 100 to 999 using C

/*WAP to detect armstrong number in 3 Digits from 100 to 999*/ #include<stdio.h> void main() { int i,j,k,number,sumcube; clrscr(); i=1; do { j=0; do { k=0; do { number=i*100+j*10+k; sumcube=(i*i*i)+(j*j*j)+(k*k*k); if(number==sumcube) printf(“%d\n”,number); ++k; } while(k<=9); ++j; } while(j<=9); i++; } while(i<=9); getch(); } Output 13 370 371 407 Download Program Download

C Program to compute sum and reverse of a given integer

/*WAP to compute sum and reverse of a given integer*/ #include<stdio.h> void main() { int sum=0,rev=0,rem,n; clrscr(); printf(“Enter The Integer-“); scanf(“%d”,&n); while(n!=0) { rem=n%10; sum=sum+rem; rev=rev*10+rem; n=n/10; } printf(“The Sum Of Digits Is =%d\n”,sum); printf(“Reversed Number Is =%d”,rev); getch(); } Output Enter The Integer-248 The Sum Of Digits Is =14 Reversed Number Is =842 Download … Read moreC Program to compute sum and reverse of a given integer

C Program to calculate roots of a quadratic equation using switch statement

/*WAP to calculate roots of a quadratic equation using switch statement*/ #include<stdio.h> #include<math.h> #include<stdlib.h> void main() { int option; float a,b,c,d,r1,r2; clrscr(); printf(“Enter The Coefficient Of A, B and C\n”);\ scanf(“%f%f%f”,&a,&b,&c); if(a==0) { printf(“Not A Quadratic Equation\n”); exit(0); } d=b*b-4*a*c; if(d==0) option=1; else if(d>0) option=2; else option=3; switch(option) { case 1:printf(“Roots Are Real and Equal … Read moreC Program to calculate roots of a quadratic equation using switch statement

C Program to find largest, smallest of 3 numbers

/*WAP to find largest, smallest of 3 numbers*/ #include<stdio.h> void main() { int a,b,c; clrscr(); printf(“Enter 3 Numbers-\n”); scanf(“%d%d%d”,&a,&b,&c); if(a>b) { if(a>c) printf(“%d Is Largest\n”,a); else printf(“%d Is Largest\n”,c); } else { if(b>c) printf(“%d Is Largest\n”,b); else printf(“%d Is Largest\n”,c); } if(a<b) { if(a<c) printf(“%d Is Smallest\n”,a); else printf(“%d Is Smallest\n”,c); } else { if(b<c) … Read moreC Program to find largest, smallest of 3 numbers