Sunday, February 27, 2011

GCD

/* Write a Program for to find the GCD of two numbers */
int gcd(int,int)
void main()
{
int no1,no2,ans;
clrscr();
printf("Enter Integer Number : ");
scanf("%d",&no1);
printf("Enter Second Number: ");
scanf("%d",&no2);
ans = gcd(no1,no2);
printf("GCD of two Number is : %d",ans);
getch();
}

int gcd(int m,int n)
{
if(n == 0)
return m;
else
gcd(n,(m%n));
}

No comments:

Post a Comment