c program to Find GCD of two number

c program to Find GCD of two number


Find G.C.D. of two numbers in C, C Assignment to find GCD of 2 numbers, Write a c program for finding gcd (greatest common divisor) of two given numbers

#include
int main () 
{
int x,y,m,i;
printf("Insert any two number: ");
scanf("%d%d",&x,&y);
if(x>y)
m=y; 
else
m=x; 
for (i=m;i>=l;i--) 
{
if(x%i==0&&y%i==0)
{
printf("\nHCF of two number is : %d",i) ;
break; 
} 
} 
return 0;
}


No comments:

Post a Comment