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
The cpu understands instructions written in a binary machine language. <br> a. true <br> b. false
Jet001 [13]

The CPU understands instructions written in a binary machine language: A. true.

<h3>What is a CPU?</h3>

CPU is an abbreviation for central processing unit and it can be defined as the main components of a computer because it acts as the “brain” of a computer and does all the processing, calculations, and logical control of the data entered through the keyboard into output that are displayed on the monitor.

This ultimately implies that, the central processing unit (CPU) performs most of the calculations, which enables a computer to function and is sometimes referred to as the “brain” of the computer.

Generally, the central processing unit (CPU) only understands instructions that are written in a binary machine language.

Read more on CPU here: brainly.com/question/5430107

#SPJ1

7 0
2 years ago
How do the portrait and landscape page orientations help in the process of printing a worksheet?
zmey [24]
Most worksheets are portrait orientation. A few of them are horizontal, but it depends on what you want to do.
6 0
3 years ago
Define a function in Scheme (or relation in Prolog) that checks whether a set of elements (represented as a list) is a subset of
mafiozo [28]

Answer:

subset([],[]).

       subset([X|L],[X|S]) :-

           subset(L,S).

       subset(L, [_|S]) :-

           subset(L,S).

Success:

     subset([1,3], [1,2,3]).

     subset(X, [1,3,4]).        % error handling to compare sets in a given order

Fail:

     subset([2,1], [1,2,3]).   % compares in a different order from the first.

Explanation:

The function "Subset" in the source code above accepts two sets, then checks if the first set is a subset of the second. The code returns true if the condition is met.

4 0
3 years ago
Sophisticated modeling software is helping international researchers ________.
MA_775_DIABLO [31]

Answer:

(A) increase the pace of research in finding and producing vaccines.

Explanation:

The production of a vaccine is an international research involving scientists and medical experts from different countries, and the use of sophisticated modeling software is helping these researchers increase the speed of research in creating vaccines. It usually takes up to 10 years of research before a vaccine is made available, but this sophisticated modeling software can help in the facilitation.

5 0
3 years ago
What is the core function of an enterprise platform
7nadin3 [17]

Answer:

The core function of an enterprise platform is that it connects the supplier with the consumer

4 0
2 years ago
Other questions:
  • Andy designed a web page for a product-oriented industry using CSS properties. He used several HTML tags to create the web page.
    6·1 answer
  • Write a method called multiconcat that takes a string and an integer as parameters. return a string that consists of the string
    6·1 answer
  • Should software companies be able to send automatic updates to your computer withoput your knowledge
    14·1 answer
  • List five ways in which the type declaration system of a language such as Java or C differs from the data definition language us
    8·1 answer
  • Which of the following is NOT an e-reader you would use as an alternative to carrying around a set of textbooks?
    13·1 answer
  • Write a function square_evens(values) that takes a list of integers called values, and that modifies the list so that all of its
    9·1 answer
  • Android OS "AFTER" Beta.<br><br> A. Cupcake<br><br> B. Candy<br><br> C. Cookie<br><br> D. Carmel
    12·1 answer
  • Como se diseña y produce un material audiovisual
    5·1 answer
  • একটি ডকুমেন্ট তৈরী করে ড্রাইভে সেভ করার পদ্ধতি বর্ণনা করো
    10·1 answer
  • Evolution of management​
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!