C Program to find HCF (Highest common factor) using while loop | Program to Find HCF in C Language

C Program to find HCF (Highest common factor) using while loop | Program to Find HCF in C Language





HCF (Highest common factor)  program with two numbers in c


#include 
int main () 
{
int nl,n2;
printf("\nEnter two numbers:"); 
scanf("%d %d",&nl,&n2); 
while(nl!=n2)
{
if(nl>=n2-l)
nl=nl-n2; else
n2=n2-nl;
}
printf("\nGCD=%d",nl); 
return 0; 
}

No comments:

Post a Comment