Skip to content

Instantly share code, notes, and snippets.

@scratchyourbrain
Created December 18, 2014 07:31
Show Gist options
  • Save scratchyourbrain/41f50169e6c1f1d57d6e to your computer and use it in GitHub Desktop.
Save scratchyourbrain/41f50169e6c1f1d57d6e to your computer and use it in GitHub Desktop.
C program to find HCF GCD
#include <stdio.h>
int main()
{
int num1, num2, i, hcf;
printf("Enter two integers: ");
scanf("%d %d", &num1, &num2);
for(i=1; i<=num1 || i<=num2; ++i)
{
if(num1%i==0 && num2%i==0) /* Checking whether i is a factor of both number */
hcf=i;
}
printf("H.C.F of %d and %d is %d", num1, num2, hcf);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment