07/03/2023

Program to Find LCM of Two Numbers in C Using While Loop

Write a c program to find the LCM of two numbers using the while loop. Program to Find LCM of Two Numbers in C. LCM (Least Common Multiple) also called the lowest common multiple or smallest common multiple If you have any questions please let me know in the Comment Box.

Program to Find LCM of Two Numbers in C Using While Loop

LCM: In arithmetic and number theory, the least common multiple, lowest common multiple, or smallest common multiple of two integers a and b, usually denoted by lcm, is the smallest positive integer that is divisible by both a and b. You can use the LCM calculator to find the LCM of Two Numbers in a matter of seconds.

Program to Find LCM of Two Numbers in C Using While Loop


#include <stdio.h>

int main()
{
	int num1, num2, max;

	/*Program to Find LCM of Two Numbers in C*/

	printf("Enter Two Number to Find LCM of Two Numbers:\n");
	scanf("%d %d", &num1, &num2);

	max = (num1 > num2) ? num1 : num2;
	while (1)
	{
		if (max % num1 == 0 && max % num2 == 0)
		{
			printf("LCM of %d And %d is %d", num1, num2, max);
			break;
		}

		++max;
	}

	return 0;
}


The Output of Find LCM of Two Numbers in C Using While Loop


The Output of Find LCM of Two Numbers in C Using While Loop

Similar to the LCM of Two Numbers in C


Previous Post
Next Post

post written by:

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.
Follow Me

0 Comments: