Shopping In MUMBAI

Are you searching for Discounts, offers, sale in Mumbai ? You are in the right place. MUMBAI, a shopping haven, has no dearth of great discounts and sales. This blog features the best MUMBAI shopping offers, sale, discounts and deals and bargains CURRENTLY GOING on in Mumbai plus a few free things thrown in on top. Don't wait for it because once they are gone, they are gone. Hurry!..By clicking the "Like" button you will receive a daily update of discounts, sale, offers going on in Mumbai. LIKE IT.... SHARE IT...njoY.

Wednesday, December 31, 2008

C Program using function to find the GCD of 2 nos recursively

Write a function to find the GCD of 2 nos recursively. Also write the main()
function to use it.

#include
#include
int gcd(int a,int b);
void main()
{
int r,g,a,b;
clrscr();
printf("Enter two numbers:");
scanf("%d %d",&a,&b);
g=gcd(a,b);
printf("GCD : %d",g);
getch();
}
int gcd (int a,int b)
{
if(b>a)
return gcd(b,a);
if(b==0)
return a;

else
return gcd(b,a%b);
}

/* Output
Enter two numbers:2
4
GCD : 2
*/

C Program using function to find the GCD of 2 nos recursivelySocialTwist Tell-a-Friend

0 comments:

SUPPORT THIS BLOG