Beta Coder

Learn code like Beta Coder.

Breaking

Sunday, September 27, 2020

C Program to Find LCM of Two Numbers

Find LCM of Two Numbers

C PROGRAM TO FIND LCM OF TWO NUMBERS
In this program we learn how to calculate LCM of two numbers by provided user using C.
C program to calculate LCM of two numbers
// FIND LCM OF TWO NUMBERS
#include<stdio.h>
#include<conio.h>
void main()
{
	int a, b, r, p;
	float l;
	clrscr();
	printf("\n Enter two number : ");
	scanf("%d%d",&a,&b);
	p = a * b;
	do
	{
		r = a % b;
		a = b;
		b = r;
	}while(r != 0);
	l = (float) p / a;
	printf("\n The L.C.D = %f",l);
	getch();
}
OUTPUT:
   Enter two numbers : 27 9
   The L.C.M = 27.oooooo

No comments:

Post a Comment