Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.40 KB | None | 0 0
  1. #include<stdio.h>
  2. int gcd;
  3. void GCD(int,int);
  4. int main()
  5. {
  6.     int n1,n2,gcd;
  7.     printf("Enter the two numbers  :\n");
  8.     scanf("%d%d",&n1,&n2);
  9.     GCD(n1,n2);
  10. }
  11. void GCD(int x,int y)
  12. {
  13.     int c;
  14.     if(x==0 )
  15.     {
  16.         gcd=y;
  17.         printf("GCD=%d\n",gcd);
  18.     }
  19.     else if(y==0)
  20.     {
  21.         gcd=x;
  22.         printf("GCD=%d\n",gcd);
  23.     }  
  24.     else if(x>y)
  25.     {
  26.         x=x-y;
  27.         GCD(x,y);
  28.     }
  29.     else
  30.     {
  31.         y=y-x;
  32.         GCD(x,y);
  33.     }
  34.    
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement