Computer C++ program to find the LCM and GCD of two numbers 2012

Advertisements

 

Computer C++ program to find the LCM and GCD of two numbers

#include
#include

void main()
{
clrscr();

int x,y,gcd=1;

cout<>x;

cout<>y;

for(int i=1;i<1000;++i)
{
if((x%i==0)&&(y%i==0))
gcd=i;
}

cout<<"\n\n\nGCD :"<
cout<<"\n\n\nLCM :"<<(x*y)/gcd;

getch();
}

OUTPUT:

ENTER 1st NO : 12

ENTER 2nd NO. :13

GCD :1

LCM :156

For further information regarding Computer C++ program to find the LCM and GCD of two numbers, connect with us on facebook, google+ and twitter.


Tags: write a program in c to compute the lcm of two numbers, write a c program to find the lcm and gcd of two numbers, c program to find lcm and hcf of two numbers, write a program in c to compute the gcd of two numbers, wap to find the lcm and gcd of two numbers, c program for lcm and gcd, using overloading and class find gcd of two numbers, c program for gcd and lcm, gcd of two numbers in c, write a c program to find lcm and gcd of two numbers


Ask a Question:

  • Explain Relative addressing mode and Base Register addressing Mode
    with example

    manoj on 01 Feb 2013
  • Lol Its Not working Bro !
    Ahahahahhaha
    Error: Your comment is too short. Please try to explain your query.

    Tejas on 06 Jan 2012
  • assuming that there are 7.481 gallons in cubic foot,write a c++ program that asksthe user to enter the number of gallons and then display the equivalent in cubic feet.

    shubhlika on 19 Nov 2011
  • i need a project based on gui aplication…..would u like to send me ……..i really need it…..please help

    saurabh on 25 Jul 2011
  • what is meant by class ,function ,variable,declaration of variable,how to declare variable,initialization,constructor,destructor,defined,implicitly declaration,explicit declaration,access specifiers?

    aakash kumbhare on 09 Jun 2011
  • Computer C++ program to find the LCM of two numbers using call by reference

    arjunkumar mishra on 07 May 2011
  • what is the result of cout<>y; and cout<>x; in the above program?

    Udit Kumar on 15 Mar 2011
  • please please do solve these questions. i need them by tomorrow if possible.
    Write a function called zerosmaller() that is passed two int arguments by reference and then sets the smaller of the two numbers to 0. Write a main() program to exercise this function and also check the effect of pass-by-reference by displaying the values of both arguments after calling the function.
    void zerosmaller (int& a, int& b)
    Use the same logic and implement another function called zerolarger() which sets the larger of the two numbers to zero.

    ali malik on 08 Mar 2011
  • Write a program that creates a one-dimensional array which can hold 10 numbers and fill the array with integer values given by the user. The output of the program should display the 10 array elements, and the output of the following functions.

    • MinVal() function which returns the smallest value in the array.
    • MaxVal() function which returns the largest value in the array.
    • Sum() function which returns the sum of all the numbers in array.
    • Duplicate() function which prints the repeated value in the array.
    • Avg() function which returns the average of all numbers in the array. You should call the Sum() function (implemented earlier) within this function.
    • printReverse() function which displays the array elements in reverse order.

    Write a menu-driven main function which calls all of the above functions using a switch statement.

    ali malik on 08 Mar 2011
  • why we use the 1000 as a limit in this problem.
    and if we use this expression(i<= (x||y) on the place of 1000 is true ora noot

    fareed on 15 Dec 2010