answersLogoWhite

0


Best Answer

For the greatest common factor, you can use the following to your advantage. As an example, take the numbers 14 and 10 as input.

The greatest common factor of 14 and 10 is the same as the greatest common factor of 10 and 4, where 4 has been obtained by subtracting 14 - 10 (or, faster, to avoid repeated subtraction, take the remainder of a division: 14 % 10).

If you divide 10 % 4 (or subtract 4 twice, from 10), you get a remainder of 2, so the new set of numbers is 4 and 2.

Next step: 4 % 2 = 0. Once you get a remainder of zero, the previous number is the answer - the number that you should return. In this case, the 2.

For the least common multiple, use the property that (using a numeric example) 14 x 10 = 2 x 70 (14 and 10 are the two parameters, 2 and 70 are the greatest common factor and the least common multiple, respectively).

For the greatest common factor, you can use the following to your advantage. As an example, take the numbers 14 and 10 as input.

The greatest common factor of 14 and 10 is the same as the greatest common factor of 10 and 4, where 4 has been obtained by subtracting 14 - 10 (or, faster, to avoid repeated subtraction, take the remainder of a division: 14 % 10).

If you divide 10 % 4 (or subtract 4 twice, from 10), you get a remainder of 2, so the new set of numbers is 4 and 2.

Next step: 4 % 2 = 0. Once you get a remainder of zero, the previous number is the answer - the number that you should return. In this case, the 2.

For the least common multiple, use the property that (using a numeric example) 14 x 10 = 2 x 70 (14 and 10 are the two parameters, 2 and 70 are the greatest common factor and the least common multiple, respectively).

For the greatest common factor, you can use the following to your advantage. As an example, take the numbers 14 and 10 as input.

The greatest common factor of 14 and 10 is the same as the greatest common factor of 10 and 4, where 4 has been obtained by subtracting 14 - 10 (or, faster, to avoid repeated subtraction, take the remainder of a division: 14 % 10).

If you divide 10 % 4 (or subtract 4 twice, from 10), you get a remainder of 2, so the new set of numbers is 4 and 2.

Next step: 4 % 2 = 0. Once you get a remainder of zero, the previous number is the answer - the number that you should return. In this case, the 2.

For the least common multiple, use the property that (using a numeric example) 14 x 10 = 2 x 70 (14 and 10 are the two parameters, 2 and 70 are the greatest common factor and the least common multiple, respectively).

For the greatest common factor, you can use the following to your advantage. As an example, take the numbers 14 and 10 as input.

The greatest common factor of 14 and 10 is the same as the greatest common factor of 10 and 4, where 4 has been obtained by subtracting 14 - 10 (or, faster, to avoid repeated subtraction, take the remainder of a division: 14 % 10).

If you divide 10 % 4 (or subtract 4 twice, from 10), you get a remainder of 2, so the new set of numbers is 4 and 2.

Next step: 4 % 2 = 0. Once you get a remainder of zero, the previous number is the answer - the number that you should return. In this case, the 2.

For the least common multiple, use the property that (using a numeric example) 14 x 10 = 2 x 70 (14 and 10 are the two parameters, 2 and 70 are the greatest common factor and the least common multiple, respectively).

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

#include#include

void main()

{

int num1 , num2 , lcm , gcd , remainder , numerator , denominator ;

clrscr();

printf( "Enter two numbers\n");

scanf(" %d%d " , &num1 , &num2 );

if (num1 > num2)

{

numerator=num1;

denominator=num2;

}

else

{

numerator = num2 ;

denominator = num1 ;

}

remainder = num1 % num2;

while ( remainder != 0)

{

numerator = denominator;

denominator = remainder;

remainder = numerator % denominator;

}

gcd = denominator;

lcm = (num1 * num2 ) / gcd;

printf("GCD of %d and %d =%d\n" , num1, num2, gcd);

printf(" LCM of %d and %d= %d\n" , num1, num2, lcm);

getch();

}

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

For the greatest common factor, you can use the following to your advantage. As an example, take the numbers 14 and 10 as input.

The greatest common factor of 14 and 10 is the same as the greatest common factor of 10 and 4, where 4 has been obtained by subtracting 14 - 10 (or, faster, to avoid repeated subtraction, take the remainder of a division: 14 % 10).

If you divide 10 % 4 (or subtract 4 twice, from 10), you get a remainder of 2, so the new set of numbers is 4 and 2.

Next step: 4 % 2 = 0. Once you get a remainder of zero, the previous number is the answer - the number that you should return. In this case, the 2.

For the least common multiple, use the property that (using a numeric example) 14 x 10 = 2 x 70 (14 and 10 are the two parameters, 2 and 70 are the greatest common factor and the least common multiple, respectively).

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program to find the L.C.M. and HCF of two number using function where numbers are passed as parameter use function with return value?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

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.


Write a program that read phrase and print the number of lower-case letter in it using function of counting?

write a program that reads a phrase and prints the number of lowercase latters in it using a function for counting? in C program


Write a java script program to print first ten odd natural numbers in C?

Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.


Program to fnd the numbers are equal in Java script?

To test if two number are equal in JavaScript, we use the == operator and compare them. The below function test if two number (a and b) are equal. The function returns 1 if a is greater, -1 if b is greater, and 0 if the numbers are of equal value. function isEqualTo( a, b ){ if ( a > b ){ return 1; } if (b > a ){ return -1; } return 0; }


A program c plus plus on automorphic numbers or not?

how to write a program that counts automorphic number from 1 to 999

Related questions

What is the value of Math.round(-122.83)?

The function round requires another parameter which indicated the degree to which the number is to be rounded. Without it the function has no meaning.


How can I write a program to display prime numbers from 1 to 100?

Write a function that implements an algorithm that checks to see if a particular integer is prime (returning a boolean). Write a program that uses that function on each number from 1 to 100, and if true, displays that number.


What is s in Laplace transforms?

The Laplace transform of a function f(t), defined for all real numbers t ≥ 0, is the function F(s), defined by: : The parameter s is a complex number: : with real numbers σ and ω. A complex number is defined as a number comprising a real numberpart and an imaginary number part. An imaginary number is a number in the form bi where b is a real number and i is the square root of minus one. (Wiki search)


How do you Write a program in 'c' language which accepts int numbers from the users print its reverse number x function which return value?

question clarity


What is a function in mathimacics?

A function is a rule to calculate a number, based on some other number (or numbers).


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.


Program to count the number of numbers in an array using 8085 microprocessor?

A program which is used to count the number of numbers in an array using a 8085 microprocessor is known as a assembly language program.


Is a single number characteristic describe a population is called a parameter?

Parameter


Write a program that read phrase and print the number of lower-case letter in it using function of counting?

write a program that reads a phrase and prints the number of lowercase latters in it using a function for counting? in C program


Write a java script program to print first ten odd natural numbers in C?

Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.


Program to fnd the numbers are equal in Java script?

To test if two number are equal in JavaScript, we use the == operator and compare them. The below function test if two number (a and b) are equal. The function returns 1 if a is greater, -1 if b is greater, and 0 if the numbers are of equal value. function isEqualTo( a, b ){ if ( a > b ){ return 1; } if (b > a ){ return -1; } return 0; }


2 Write a program to print a following program?

USING STRING LITERAL VALUES TO ADD 2 NUMBERS If you just want to show the outcome of two numbers you have: PRINT 4 + 5 This will print '9' the answer to 4 + 5. If you want to show the addition: PRINT "4 + 5 = "; 4 + 5 This will show the question and then calculate the answer. If you want the user to input numbers to add, use variables and then add them the same way. ====== COLLECTING USER INPUT FROM THE KEYBOARD/USING NUMERIC VARIABLES In the following example, the end user can get to interact with the program by typing in their numbers at the keyboard; then, pressing the [Enter] key. CLS PRINT "PROGRAM: Add 2 numbers" PRINT INPUT "Enter the 1st number: ", number1 INPUT "Enter the 2nd number: ", number2 PRINT sumTotal=number1+number2 PRINT "The sum total is: "; sumTotal PRINT INPUT "Again, Y/N"; yesNo$ IF UCASE$(LEFT$(yesNo$,1))="Y" THEN RUN END ====== CREATE FUNCTION/THEN, MAKE A FUNCTION CALL TO ADD 2 NUMBERS Another way to write this program is to create a function/then, make a function call... '*** PROGRAM: Add 2 numbers... '*** Variable declaration list... number1=7 '...initialise numeric variable 1 number2=3 '...initialise numeric variable 2 '*** Main program... CLS '...(CL)ear the (S)creen PRINT add(number1,number2) '...make function call/passing in 2 numbers to add END '...END of program/halt program code execution '*** Function(s)... FUNCTION add(num1,num2) '...this line marks the start of the Function add=num1+num2 '...this line returns the sum total of the 2 numbers END FUNCTION '...this line marks the end of the Function