AedenCak3

C program to find Greatest Common Divisor (GCD ) of two given integers

Nov 30th, 2021
723
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. int main()
  3. {
  4.     int n1, n2, i, gcd;
  5.  
  6.     printf("Enter two integers: ");
  7.     scanf("%d %d", &n1, &n2);
  8.  
  9.     for(i=1;i <= n1 && i <= n2; i++)
  10.     {
  11.         if(n1%i==0 && n2%i==0)
  12.         gcd = i;
  13.     }
  14.     printf("%d", gcd);
  15. }
  16.  
RAW Paste Data