Ques=> Recursive function to find out the GCD of numbers.
CODE=>
#include<stdio.h>
#include<conio.h>
int gcd(int x, int y)
{
int rem;
if(y==0)
return x;
else
{
rem=x%y;
return(gcd(y,rem));
}
}
void main()
{
int a,b,g;
//clrscr();
printf("Enter two numbers - ");
scanf("%d%d",&a,&b);
g=gcd(a,b);
printf("G.C.D of %d and %d is = %d",a,b,g);
getch();
}
OUTPUT=>
CODE=>
#include<stdio.h>
#include<conio.h>
int gcd(int x, int y)
{
int rem;
if(y==0)
return x;
else
{
rem=x%y;
return(gcd(y,rem));
}
}
void main()
{
int a,b,g;
//clrscr();
printf("Enter two numbers - ");
scanf("%d%d",&a,&b);
g=gcd(a,b);
printf("G.C.D of %d and %d is = %d",a,b,g);
getch();
}
OUTPUT=>
No comments:
Post a Comment