Created
December 18, 2014 07:31
-
-
Save scratchyourbrain/41f50169e6c1f1d57d6e to your computer and use it in GitHub Desktop.
C program to find HCF GCD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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