GCD of Two Numbers Without using LCM in C

include

int main()
{
int no1,no2,temp_variable,gcd;
scanf(“%d%d”,&no1,&no2);
while(no2!=0)
{
temp_variable=no2;
no2=no1%no2;
no1=temp_variable;
}
gcd=no1;
printf(“gcd of two numbers is %d”,gcd);
}

OUTPUT for GCD
INPUT:
96
12
OUTPUT:
gcd of two numbers is 12

Leave a Reply

Your email address will not be published.