answersLogoWhite

0

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

Updated: 8/20/2019
User Avatar

Wiki User

12y ago

Best Answer

#include<stdio.h>

main()

{

int a,b,i,lcm,gcf;

printf("\n Enter two numbers");

scanf("%d%d",&a,&b);

for(i=0;i<=a;i++)

{

if((b%i==0)&&(a%i==0))

{

gcf=i;

}

}

lcm=a*b/gcf;

printf("\n GCF is %d and LCM is %d",gcf,lcm);

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you find the LCM and GCF of two no in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the LCM of 200?

The 'c' in 'gcf' stands for "common". "Common" means "same for both". There's nothing common about one single item, and a single number has no 'common' factors. It takes at least two.


What is the LCM and GCF of 73?

You lose both ways. In both "LCM" and "GCF", the 'C' in the middle means "Common", and "Common" means "same for both". A single thing can't have anything 'common'. 'Common' means "the same for two or more things". You can't have a 'LCM' or a 'GCF' until you have at least two numbers.


What are the numbers that have 7 as their GCF?

You need at least two numbers to find a GCF.


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.


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 the HCF for the number 4?

the GCF of 4 3 5 is 1


What does gcf and LCM means?

gcf implies greatest common factor or divisor(gcd) while LCM mean least common multiple.given two integers a and b (a,b) will denote the positive gcf of the integers.Thus 2=(2,4 )=(-2,4)=(-2,-4)=(2,4).Also, for any integer a and b, we have that (a,-b)=(a,b)=(-a,b)=(-a,-b)=(b,a). Similarly, any two non-zero integer a and b have a positive gcd(a,b), and also have a least positive common multiple(LCM). The LCM is denoted by [a,b] i.e a square bracket. note that for gcd, we use an ordinary bracket. It is also worth to know the relationship between gcd and LCM.This is given by: [a,c]=|ac|/( a,c) for any non-zero integers a and c. Take note that |ac| implies the absolute value of a*c. Thanks. Ans. by: Olawale O.A


What is the GCF of c-17?

You need at least two terms to find a GCF. C - 17 is one term.


What is the least common multiple of 4?

You need two numbers to find a least common multiple. The LCM (least common multiple) is the smallest positive whole number exactly divisible by two or more given whole numbers. The C in LCM stands for common and in general we only talk about common multiples of two or more numbers.You need at least two numbers to find an LCM.


Program in 'c' to find the LCM of any given five numbers?

Just write a method or function that calculates the LCM for two numbers at a time. Then calculate the LCM for the first two numbers, get the LCM of the result with the third number, etc.Just write a method or function that calculates the LCM for two numbers at a time. Then calculate the LCM for the first two numbers, get the LCM of the result with the third number, etc.Just write a method or function that calculates the LCM for two numbers at a time. Then calculate the LCM for the first two numbers, get the LCM of the result with the third number, etc.Just write a method or function that calculates the LCM for two numbers at a time. Then calculate the LCM for the first two numbers, get the LCM of the result with the third number, etc.


Lcm and GCF in c plus plus?

#include&lt;iostream.h&gt; void main() { int x,y,r,a,b; cout&lt;&lt;"enter the two numbers"; cin&gt;&gt;x&gt;&gt;y; a=x; b=y; while(x%y!=0) { r=x%y; x=y; y=r; } cout&lt;&lt;"GCF="&lt;&lt;y&lt;&lt;"\n"; cout&lt;&lt;"LCM="&lt;&lt;a*b/y; }


What is 32's GCF?

You need at least two numbers to find a GCF.