WAP in C to Find LCM of two Numbers?

#include<stdio.h>
#include<conio.h>
int main()
{
int n1, n2, min;
printf(“Enter two positive numbers: “);
scanf(“%d %d”, &n1, &n2);
// maximum number between n1 and n2 is stored in min
min = (n1>n2) ? n1 : n2;
// This Condition Is Always true
while(1)
{
if( min%n1==0 && min%n2==0 )
{
printf(“The LCM of %d and %d is %d.”, n1, n2,min);
break;
}
min++;
}
getch();
return(0);
}

Output :-

lcm.png

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s