C program to find HCF or GCD
C program to find HCF and GCD: The code below finds the highest common factor of two integers. HCF is also known as the greatest common divisor (GCD) or the greatest common factor (GCF)
#include <stdio.h>
#include<conio.h>
Vode main()
{
int a, b, i, gcd;
int a, b, i, gcd;
printf("Enter two integers\n");
scanf("%d%d", &a, &b);
scanf("%d%d", &a, &b);
for (i=1;i<a && i<b; ++i)
{
if(a%i==0 && b%i==0)
{
gcd=i;
}
}
printf("Greatest common divisor of %d and %d = %d\n", a, b, gcd);
getch();
}
}
No comments:
Post a Comment
for more information please share like comment and subscribe