Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


write a c-program to find gcd using recursive functions

Answers were Sorted based on User's Feedback



write a c-program to find gcd using recursive functions..

Answer / pavan_mustyala

int gcdRecurse(int a, int b)
{
int temp;

// error handling to prevent divide by zero
if(!b)
{
return b;
}

temp = a % b;

if (temp == 0)
{
return(b);
}
else
{
return(gcdRecurse(b, temp));
}
}

Is This Answer Correct ?    30 Yes 11 No

write a c-program to find gcd using recursive functions..

Answer / rakib hyder

#include<stdio.h>
int gcd(int a,int b)
{
if(a==0)
return b;
else if(b==0)
return a;
else if(a>b)
return gcd(b,a%b);
else
return gcd(a,b%a);
}

Is This Answer Correct ?    12 Yes 7 No

write a c-program to find gcd using recursive functions..

Answer / arun ananda jadhav

int gcd(int num1,int num2)
{
if(nu1%num2)
{
return(gcd(num2,num1%num2));
}
else
{
return(1);
}
}

Is This Answer Correct ?    15 Yes 13 No

write a c-program to find gcd using recursive functions..

Answer / deepak

#include<stdio.h>
int main(){
int n1,n2,gcd;
printf("\nEnter two numbers: ");
scanf("%d %d",&n1,&n2);
gcd=findgcd(n1,n2);
printf("\nGCD of %d and %d is: %d",n1,n2,gcd);
return 0;
}

Is This Answer Correct ?    1 Yes 0 No

write a c-program to find gcd using recursive functions..

Answer / abilash k alex

what is gcd?

Is This Answer Correct ?    10 Yes 13 No

Post New Answer

More C Code Interview Questions

How do you write a program which produces its own source code as its output?

7 Answers  


main() { int x=5; clrscr(); for(;x<= 0;x--) { printf("x=%d ", x--); } } a. 5, 3, 1 b. 5, 2, 1, c. 5, 3, 1, -1, 3 d. –3, -1, 1, 3, 5

2 Answers   HCL,


why java is platform independent?

13 Answers   Wipro,


void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }

2 Answers  


How to read a directory in a C program?

4 Answers  


print numbers till we want without using loops or condition statements like specifically(for,do while, while swiches, if etc)!

11 Answers   Wipro,


C statement to copy a string without using loop and library function..

2 Answers   Persistent, TCS,


Design an implement of the inputs functions for event mode

0 Answers   Wipro,


how can i search an element in an array

2 Answers   CTS, Microsoft, ViPrak,


#include<stdio.h> main() { FILE *ptr; char i; ptr=fopen("zzz.c","r"); while((i=fgetch(ptr))!=EOF) printf("%c",i); }

1 Answers  


main() { int i=5; printf("%d",++i++); }

1 Answers  


How to count a sum, when the numbers are read from stdin and stored into a structure?

1 Answers  


Categories