HCF of two numbers in C - C Program to find HCF (Highest common factor) program with two numbers



 c program to find hcf program with two numbers

Learn C - C tutorial - c program to find hcf program with two numbers - C examples - C programs

C Program to find HCF (Highest common factor) program with two numbers

  • The number divides exactly two or more numbers is said to be HCF (Highest common factor)
  • HCF is also known as the greatest common divisor (GCD) or the greatest common factor (GCF).

Sample code

#include<stdio.h>
int main()
{
    int number_1=6,number_2=3;
    printf("\nTwo numbers:6,3");
    while(number_1!=number_2)
    {
        if(number_1>=number_2-1)
            number_1=number_1-number_2;
        else
            number_2=number_2-number_1;
    }
    printf("\nGCD=%d",number_1);
    return 0;
}

Output

Two numbers:6,3
GCD=3


View More Quick Examples


Related Searches to HCF of two numbers in C - C Program to find HCF (Highest common factor) program with two numbers