# C Program To Implement The GCD Or HCF Factor

C Program to Implement The Greatest Common Divisor Or Highest Common Factor.

GCD is also called the HCF(Highest Common Factor). Suppose we want to calculate gcd or hcf of 16 and 24, here are the steps that are being implemented in c program for gcd: 1. Find the factors of 16. i.e 2*2*2*=16 and factors of 24 is 2*2*2*3=24. 2. Find all the common factors of 16 and 24. And multiply all the common factors or same factors, i.e 2*2*2 = 8. Hence gcd or hcf of 24 and 16 is 8.

`ALGORITHM:-step 1 : Startstep 2 : Enter Two number to calculate GCDstep 3 : Calculate the Greatest Common Divisorstep 4 : Stop Execution`

`PROGRAM CODE:-#include<stdio.h>#include<conio.h>void hcf(int a,int h){    int temp;    while(1)    {         temp = a%h;         if(temp==0)         return h;         a = h;         h = temp;    }}int main(){     int c,d,e;     printf("enter values to find gcdn");      scanf("%d%d",&c,&d);     e=hcf(c,d);     printf("ngcd of %d and %d is %d.",c,d,e);     getch();}`

`OUTPUT:-Enter Two number to calculate Greatest common divisor1624GCD of 16 and 24 is: - 8.`
`C Program To Calculate the Greatest Common factor (GCD)How to calculate GCD using cGreatest Common Disisor using C.`