Function call in C Language 03-maximum common divisor and minimum common multiple
// Function call/* ========================================== =============================== question: calculate the maximum common divisor and the least common multiple of two numbers. For example, the maximum common divisor of 16 and 12 is: 4 16 and 12 have the following least common multiples: 48 ============================================== ===================== */# include
Int GY (int m, int n) {int t, r; if (n> m) {t = m; m = n; n = t ;} while (r = m % n )! = 0) {m = n; n = r;} return (n);} int GB (int m, int n) {int k; k = m * n/GY (m, n); return (k);} main () {int x, y, gys, gbs; printf (enter two numbers :); scanf (% d, & x, & y); gys = GY (x, y); gbs = GB (x, y ); printf (the maximum common divisor of % d and % d is: % d, x, y, gys); printf (the minimum common multiples of % d and % d are: % d, x, y, gbs );} /* ===================================================== ============================= rating: write two independent functions GB-calculate the least common multiple and GY-calculate the maximum common number, so that the program is very compact and well maintained and checked. ========================================================== ========================