1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
OLga [1]
3 years ago
12

Implementations in c++ programming when finding lcm and gcd in c++​

Computers and Technology
1 answer:
vazorg [7]3 years ago
7 0

Answer:

#include<iostream>

using namespace std;

int lcm(int m, int n) {

  int a;

  a = (m > n) ? m: n;

  while (true) {

     if (a % m == 0 && a % n == 0)

        return a;

        ++a;

  }

}

int gcd(int m, int n) {

  int r = 0, a, b;

  a = (m > n) ? m : n;

  b = (m < n) ? m : n;

  r = b;

  while (a % b != 0) {

     r = a % b;

     a = b;

     b = r;

  }

  return r;

}

int main(int argc, char **argv) {

  cout << "Enter the two numbers: ";

  int m, n;

  cin >> m >> n;

  cout << "The LCM of two numbers is: " << lcm(m, n) << endl;

  cout << "The GCD of two numbers is: " << gcd(m, n) << endl;  

  return 0;

}

Explanation:

You might be interested in
WILL GIVE A BRAINLIEST!!! PLS HELP!!!
Fittoniya [83]

Answer:

Never gonna give you up

Never gonna let you down

Never gonna run around and desert you

Never gonna make you cry

Never gonna say goodbye

Never gonna tell a lie and hurt you

Never gonna give, never gonna give

(Give you up)

We've known each other for so long

Your heart's been aching but you're too shy to say it

Inside we both know what's been going on

We know the game and we're gonna play it

I just wanna tell you how I'm feeling

Gotta make you understand

Never gonna give you up

Never gonna let you down

Never gonna run around and desert you

Never gonna make you cry

Never gonna say goodbye

Never gonna tell a lie and hurt you

Never gonna give you up

Never gonna let you down

Never gonna run around and desert you

Never gonna make you cry

Never gonna say goodbye

Never gonna tell a lie and hurt you

Never gonna give you up

Never gonna let you down

Never gonna run around and desert you

Never gonna make you cry

Never gonna say goodbye

7 0
2 years ago
What is the relationship between interoperability and the other quality attributes highlighted in this book? For example, if two
Lina20 [59]

Answer:

Interoperability is the ability of or degree to which two or more systems usefully exchange information via interfaces in particular context. Interoperability can be defined in two ways which includes the ability to exchange data (syntactic interoperability) and also the ability to correctly interpret the data being exchanged (semantic interoperability).

If two systems failed to exchange information properly, it means they are not clear to interpret and not easy to communicate and get proper information from each other and that might result in a failed communication which is in turn result in security flaw.

Other quality attributes strongly related (at least potentially) to interoperability is Application Programming Interface (API)

API is a software intermediary that allows two applications to communicate to each other and are necessary for systems interoperability.

8 0
3 years ago
An administrator has initiated the process of deploying changes from a sandbox to the production environment using the Force IDE
Pani-rosa [81]

Option A because the environment should be selected for which the changes are to be applied. In a time Force IDE has many project environments for example maybe a java project and C++ project would be there on sandbox, so the environment selection is important.

Option B because the related changed sets should be specified so that other developers that have access to the project can see the changes being made.

Option D The data fields that are needed to be deployed should also be provided so that the updated version can be seen by other developers.

Rejected Options :

Option C user name and password has nothing to do with the production environment because if the user has it only then it can come and make changes.

6 0
3 years ago
A hockey stick hits a puck on the ice. identify an action-reaction pair in this situation.
Alika [10]
The stick exerts a force on the puck; the puck exerts a force on the stick.
7 0
3 years ago
An _____provider is a business that provides individuals and companies access to the internet for free
boyakko [2]

Answer:A B

access provider Business that provides individuals and companies access to the Internet free or for a fee.

Explanation:

6 0
2 years ago
Read 2 more answers
Other questions:
  • The project started the development of inter-network connections using tcp/ip that has evolved into the internet today.
    5·1 answer
  • Which of the acronyms listed below refers to a series of basic hardware diagnostic tests performed by the startup BIOS after the
    13·1 answer
  • Find the 65th percentile from the data. The data consist of class interval from 0-10, 10-20, 20-30, 30-40, 40-50, 50-60 and freq
    8·1 answer
  • Which area of physics governs wireless communication?
    10·2 answers
  • Write a program that displays in the title of the window the position of the mouse as the user moves the mouse around the window
    5·1 answer
  • Recovery after a disaster involves installing the most recent ________ backup copy.
    15·1 answer
  • Our readings so far explored computer hardware and software, in particular operating systems and application software. There are
    11·1 answer
  • Instruction: Decide what the total marketing budget will be, and make a list of at least four things you will spend money on and
    15·1 answer
  • Please help me asapppp!​
    8·2 answers
  • When you add encryption to a powerpoint presentation what does it do
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!