clrscr( );
printf(“\n Enter the two numbers to find their gcd:”);
scanf(“%d %d”, &a, &b);
if ( a > b)
res = gcd(a, b);
else
res = gcd (b, a);
printf(“\n The GCD of %d and %d = %d”, a, b, res);
getch( );
}
gcd( int x, int y)
{
int r;
r = x % y;
if ( r = = 0)
return (y);
else
return (y, r);
}
Do'stlaringiz bilan baham: