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
An automated search feature used by search engines to find results that match your search terms is called a spider or _______. A
Sphinxa [80]

The answer is C: Crawler

The job of a search crawler and a web spider is the same. Actually, a search engine has many different names, such as automatic indexers and web spiders. A crawler is a program that browses the World Wide Web systematically in order to provide updated data to the particular search engine. Its purpose is to create entries for a search engine index. A crawler works by getting a list of URL’s to visit and store. It gets copies which it stores to the search engine to later index.

4 0
3 years ago
Read 2 more answers
Brent recently received funding for his fast-food chain in Michigan. As a result, he hires Angela to set up a top-level domain s
Elena-2011 [213]

The option among the top level domain names that Angela should opt for under such requirements is .biz.

<h3>What's a domain name? </h3>

Domain names are known to be formed to create IP addresses very easy so that one can easily remember.

Note that the domain name of biz is better for Angela to use as it is suitable for her business and as such, The option among the top level domain names that Angela should opt for under such requirements is .biz.

Learn more about domain name from

brainly.com/question/17062016

#SPJ1

5 0
2 years ago
11. Explain different types of program control with suitable flow chart.<br> N
melamori03 [73]

hi

Counting a sequence of statements without any decisions or branches as one control structure (as many computer scientists do),the if, if-else, and if-else-if ladders as one control structure,the three types of loops (while, do-while, and for) as three different control structures,the break and continue statements, in the context of loops, as one more (although this can be debatable),the switch/case control structure as one,the call/return mechanism as one,the ability to specify and call a callback function as one,the goto/label as one,and the setjmp/longjmp non-local goto as one,

5 0
2 years ago
Laura is confused with the spelling of the word pronunciation. She types the word pronunciation. Which feature of the auto corre
larisa [96]
I think this answer is b
5 0
3 years ago
Read 2 more answers
Is the flow of power reversible in a leadscrew?
Kamila [148]

Explanation:

The flow of power is not reversible. The lead screw's force is increased. It's direction of travel is reversible. ... Increases force, not torque, because the output is in a linear direction.

4 0
3 years ago
Other questions:
  • Windows uses a memory-management technique known as ________ to monitor which applications you frequently use and preloads them
    15·1 answer
  • Francis works in the human resources division of a large oil and gas company in Texas. Francis' tasks include maintaining payrol
    14·1 answer
  • Which area would a Gaming Designer fall under? Research and explain why you think so. Make sure to site your source and where yo
    7·1 answer
  • In a particular jurisdiction, taxi fares consist of a base fare of $4.00, plus $0.25 for every 140 meters traveled. Write a func
    11·1 answer
  • Files containing ____ are available from a variety of sources.
    10·1 answer
  • What is the feature of ram for beginners
    5·2 answers
  • In your opinion, why did Proponents<br>of IPs used IPV6 instead of IPv5​
    7·1 answer
  • Two things every professional PowerPoint presentation should have
    8·1 answer
  • Does the colour intesity change of the liquid if you add more baking soda?​
    6·1 answer
  • The conversion rate is the percentage of what? A. Customers who received cold calls B. Sales leads who reached the interest stag
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!