C Program to Find GCD of two Numbers Using Recursion



GCD of two integers is the largest integer that can exactly divide both numbers without remainder



  1. // C program to find gcd using recursion
  2. #include <stdio.h>
  3. int main()
  4. {
  5. int no1, no2;
  6. printf("Enter two positive integers: ");
  7. scanf("%d %d", &no1, &no2);
  8. printf("G.C.D of %d and %d is %d.", no2, no2, gcd(no1,no2));
  9. return 0;
  10. }
  11. int gcd(int no1, int no2)
  12. {
  13. if (no2 != 0)
  14. return gcd(no2, no1%no2);
  15. else
  16. return no1;
  17. }

Output
Output!
download android app

Popular C Examples









codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube