# C program find the GCD of the 2 numbers using functions

## GCD of two numbers using functions

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
/*WAP to find the GCD of the 2 numbers using functions*/ #include<stdio.h> void main() { int gcd(int,int); int m,n; clrscr(); printf("Input 2 Numbers-\n"); scanf("%d%d",&m,&n); printf("GCD of %d and %d is %d",m,n,gcd(m,n)); getch(); } int gcd(int x, int y) { while(x!=y) { if(x>y) x=x-y; else if(y>x) y=y-x; } return(x); } |

## Output

1 2 3 |
Input 2 Numbers- 12 24 GCD of 12 and 24 is 12 |

Comments are closed, but trackbacks and pingbacks are open.