1: #include <stdio.h>
2: int main() {
3: int a, b, x, y, t, gcd, lcm;
4: printf("Enter two integers\n");
5: scanf("%d%d", &x, &y);
6: a = x;
7: b = y;
8: while (b != 0) {
9: t = b;
10: b = a % b;
11: a = t;
12: }
13: gcd = a;
14: lcm = (x*y)/gcd;
15: printf("Greatest common divisor of %d and %d = %d\n", x, y, gcd);
16: printf("Least common multiple of %d and %d = %d\n", x, y, lcm);
17: return 0;
18: }
getsprogramming Tutorials , C Programming, CPP Programming and JAVA Programming , Python Programming , Javascript Programming Welcome to getsprogramming Blog Here You Find Different Programs in Easier way to Explain and gain Knowledge and Try Your Self..Thanks
Monday, 6 July 2015
Write C Program To Find LCM and HCF
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment