/*gcd.c */ /*get greatest common divisor of integer two numbers */ /*Author: Weiwei Chen */ /*Date: Oct. 31. 2010 */ /*preprocessor directives*/ #include /*function declaration*/ int gcd(int, int); /*function defintions*/ int main(void) { int i, j, res; printf("Please input two numbers: \n"); printf(" i = "); scanf("%d", &i); printf(" j = "); scanf("%d", &j); res = gcd(i, j); printf("The GCD of %d and %d is %d \n", i, j, res); return 0; } int gcd(int a, int b) { int t; while(b != 0) { t = b; b = a % b; a = t; } return a; }