C Program to find HCF of given number

This C Program to find HCF of given number Explains Clearly Step by Step how to find HCF

HCF: The Highest Common Factor of two (or more) numbers is the largest number that divides evenly into both numbers. In other words the H.C.F is the largest of all the common factors.


#include <stdio.h>
void main()
{
int n1, n2;
printf(“Enter two integers: “);
scanf(“%d %d”,&n1,&n2);
while(n1!=n2)
{
if(n1 > n2)
n1 -= n2;
else
n2 -= n1;
}
printf(“GCD = %d”,n1);
}

Share this