C Online Compiler
Example: C Program to Find LCM of Two Numbers using While loop
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// C Program to Find LCM of Two Numbers using While loop #include <stdio.h> int main() { int p, q, x; // p & q - To store the two positive numbers // x - To store the LCM number printf("-----Enter the two positive integer numbers-----\n"); scanf("%d %d", &p, &q); x = p > q ? p : q; while (1) { if (x % p == 0 && x % q == 0) { printf("\nThe LCM of the %d and %d numbers is %d.\n", p, q, x); break; } ++x; } return 0; }
80 110
Output
Clear
ADVERTISEMENTS