The greatest common divisor is also known as the greatest common factor (GCF), highest common factor (HCF), greatest common measure (GCM), or highest common divisor.
Read: C++ Program To Find GCD Using Functions
GCD of Two Numbers in C
#include <stdio.h>
/*C program to find the GCD of two numbers using FOR Loop*/
int main()
{
int num1, num2, i, hcf;
printf("Enter Two Numbers to ind the GCD:\n");
scanf("%d %d", &num1, &num2);
for (i = 1; i <= num1 || i <= num2; ++i)
{
if (num1 % i == 0 && num2 % i == 0)
hcf = i;
}
printf("GCD(Greatest Common Divisor) of %d and %d is %d", num1, num2, hcf);
return 0;
}
The Output of GCD of Two Numbers
Similar to the GCD of Two Numbers
- C Program To Find Area And Circumference Of Circle
- C Program To Print ASCII Value Of Character
- C Program To Find Area Of Triangle
- C Program to Convert a person's name into Abbreviated
- C Program For Calculate A Simple Interest
- C Program To Find Greater No. Among given Three Number
- C Program For Find The Gross Salary Of An Employee
- C Program For Calculate Percentage Of 5 Subjects
- C Program For Converting Temperature Celsius Into Fahrenheit
- C Program To Display Size Of Different Datatype
0 Comments: