Question:

Published on: 12 October, 2024

**Write a C procram to G.C.D. of two no. using recursion.**

Answer:

#include<stdio.h> #include<conio.h> int gcd(int,int); main() { int a,b,temp,result; printf("\n Enter two numbers"); scanf("%d %d",&a,&b); if(a<b) { temp=a; a=b; b=temp; } result=gcd(a,b); printf("\n The G.C.D=%d",result); getch(); } int gcd(int x,int y) { int rev; rev=x%y; if(rev==0) return(y); else y=gcd(y,rev); }

Output:

Subjects

Trending

**Write a C program to calculate the following sum: **

Sum = 1-x^2/2!+x^4/4!-x^6/6!+x^8/8!-x^10/10!

View : 703

12 October, 2024

**Write a C- Program To Count The Lines, Words, Characters In A Given Text.**

View : 688

12 October, 2024

Random questions

Write the recursive algorithm to find x^ n.

12 October, 2024

12 October, 2024

12 October, 2024

12 October, 2024

What is a Judy array?

12 October, 2024

**Write a C program to find the roots of a quadratic equation.**

12 October, 2024