Highest Common Factor(HCF) of two numbers in C

In this example, we will learn to find the HCF in c program of two numbers using different loops and conditions. 

Below I shared source code in user have to enter two numbers and for loop checks conditions. Can both values be less or equal to the values of I's? if yes, then if the condition checks for a%i==0&&b%i==0 and condition true then the value of i is highest common factor of two numbers.

HCF Program in C

int main(){
int hcf,i,a,b;
        printf("a = %d",a);
        printf("b = %d",b);
printf("HCF = %d",hcf);
return 0;


a = 12
b = 20
HCF = 4
In the above article, we discuss HCF in c program and don't forget to share your experience in the comment box.

Happy Coding 😊

If you have any doubts, Please let me know

Previous Post Next Post

Contact Form