answersLogoWhite

0

How do you find the LCM in C?

Updated: 10/17/2024
User Avatar

Wiki User

13y ago

Best Answer

Problem Statement for LCM:

Enter Two digits by a user and get its LCM

Answer:

#include

#include

void main()

{

int x,y,i,j;

clrscr();

printf("Enter Two Digits");

scanf("d",&x,&y);

for(i=1;i<=x;i++)

{

for(j=1;j<=y;j++)

{

if(y*i==x*j)

{

printf("LCM is %d\n",y*i);

i=i+x;

}

}

}

getch();

}

OR

there will be another easy way to solve it...

Answer:

#include

#include

void main()

{

int x,y,i,;

clrscr();

printf("Enter Two Digits = ");

scanf("d",&x,&y);

for(i=1;i<=x*y;i++) {

if(i%x==0&&i%y==0)

{

printf(LCM is %d",i);

break;

}

}

getch();

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you find the LCM in C?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How can you find the Lowest common denominator of four integers?

lcm(a,b,c,d) = lcm(lcm(a,b,c),d) = lcm(lcm(a,b),lcm(c,d))


What is is the LCM of18?

You cannot find the LCM of one number. There must be two numbers to compare, because the C means common.


What is the LCM of 6 7 and C?

If C is co-prime with 6 and with 7, then LCM(6, 7, C) = 42*C If not, the answer depends on the value of C.


What is the LCM of 8 and C and C?

That would depend on the value of C.


What is the LCM of A B and C?

That depends on the values of A, B and C.


What does C mean in LCM?

The C stands for Common.


What is the LCM of C and A?

If they have no common factors other than 1, the LCM is their product.


How do you find the LCM of 3 numbers through the common division method?

Find the LCM of the first two numbers and then find the LCM of that number and the third one. That answer will be the LCM of all three.


How do you find the LCM and GCF of two no in c?

#include&lt;stdio.h&gt; main() { int a,b,i,lcm,gcf; printf("\n Enter two numbers"); scanf("%d%d",&amp;a,&amp;b); for(i=0;i&lt;=a;i++) { if((b%i==0)&amp;&amp;(a%i==0)) { gcf=i; } } lcm=a*b/gcf; printf("\n GCF is %d and LCM is %d",gcf,lcm); }


How do you find out the LCM for 36?

You need at least two numbers to find an LCM.


Find the LCM of 50?

Two or more numbers are needed to find the LCM


How do you find the LCM for 24?

You need at least two numbers to find an LCM.