C Program to Find GCD of two Numbers
GCD of two integers is the largest integer that can exactly divide both numbers without remainder.
- #include <stdio.h>
- int main()
- {
- int no1, no2, i, gcd;
- printf("Enter two integers: ");
- scanf("%d %d", &no1, &no2);
- for(i=1; i <= no1 && i <= no2; ++i)
- {
- // Checks if i is factor of both integers
- if(no1%i==0 && no2%i==0)
- gcd = i;
- }
- printf("G.C.D of %d and %d is %d", no1, no2, gcd);
- return 0;
- }
Output

Solution not working or have any suggestions? Please send an email to [email protected]
Download Android App