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
you want to implement a protocol on your network that allows computers to find the ip address of a host from a logical name. whi
aniked [119]

The protocol that should be implemented is that one needs to enable hosts on the network to find the IP address.

<h3>What is IP address?</h3>

It should be noted that IP address simply means a unique address that defines a device on the internet.

In this case, the protocol that should be implemented is that one needs to enable hosts on the network to find the IP address.

Learn more about IP address on:

brainly.com/question/24930846

#SPJ12

7 0
1 year ago
It is the way to convey a message,an idea,a picture,or speech that is received and understood clearly and correctly by the perso
Goryan [66]

Answer:

Communication.

Explanation:

Communication can be defined as a process which typically involves the transfer of information from one person (sender) to another (recipient), through the use of semiotics, symbols and signs that are mutually understood by both parties.

In this context, communication is the way to convey a message, an idea, a picture, or speech that is received and understood clearly and correctly by the person for whom it is sent.​

Generally, the linear model of communication comprises of four (4) main components and these are;

1. Sender (S): this is typically the source of information (message) or the originator of a message that is being sent to a receiver. Thus, they are simply the producer of a message.

2. Channel (C): this is the medium used by the sender for the dissemination or transmission of the message to the recipient. For example, telephone, television, radio, newspapers, billboards etc.

3. Message (M): this is the information or data that is being sent to a recipient by a sender. It could be in the form of a video, audio, text message etc.

4. Receiver (R): this is typically the destination of information (message) or the recipient of a message that is being sent from a sender.

8 0
2 years ago
Input 3 positive integers from the terminal, determine if tlrey are valid sides of a triangle. If the sides do form a valid tria
butalik [34]

Answer:

In Python:

side1 = float(input("Side 1: "))

side2 = float(input("Side 2: "))

side3 = float(input("Side 3: "))

if side1>0 and side2>0 and side3>0:

   if side1+side2>=side3 and side2+side3>=side1 and side3+side1>=side2:

       if side1 == side2 == side3:

           print("Equilateral Triangle")

       elif side1 == side2 or side1 == side3 or side2 == side3:

           print("Isosceles Triangle")

       else:

           print("Scalene Triangle")

   else:

       print("Invalid Triangle")

else:

   print("Invalid Triangle")

Explanation:

The next three lines get the input of the sides of the triangle

<em>side1 = float(input("Side 1: ")) </em>

<em>side2 = float(input("Side 2: ")) </em>

<em>side3 = float(input("Side 3: ")) </em>

If all sides are positive

if side1>0 and side2>0 and side3>0:

Check if the sides are valid using the following condition

   if side1+side2>=side3 and side2+side3>=side1 and side3+side1>=side2:

Check if the triangle is equilateral

<em>        if side1 == side2 == side3: </em>

<em>            print("Equilateral Triangle") </em>

Check if the triangle is isosceles

<em>        elif side1 == side2 or side1 == side3 or side2 == side3: </em>

<em>            print("Isosceles Triangle") </em>

Otherwise, it is scalene

<em>        else: </em>

<em>            print("Scalene Triangle") </em>

Print invalid, if the sides do not make a valid triangle

<em>    else: </em>

<em>        print("Invalid Triangle") </em>

Print invalid, if the any of the sides are negative

<em>else: </em>

<em>    print("Invalid Triangle")</em>

4 0
2 years ago
Henry is designing a document for his architecture project. In which order should Henry preform the different tasks that are req
nadezda [96]

It is

Select an appropriate layout

Decide which current format...

Import or compose...

Proofread...

Check the print preview..

4 0
3 years ago
Your license can be canceled if you __________
Elena L [17]
Its B i think hope this helps ! 
8 0
3 years ago
Read 2 more answers
Other questions:
  • As you move the click and type pointer around the document, the icon changes to represent ____________________ that will be appl
    10·2 answers
  • Tell me about how to build robots
    11·1 answer
  • Describe the best way to deal with a difficult co-worker?
    13·2 answers
  • Complete the statement below using the correct term.<br>Website managers use<br>every day​
    11·2 answers
  • Which of the following was most likely used to apply red background and font to some of the cells in column D?
    10·1 answer
  • Having sound enhances your App, do you agree with this? Explain.
    9·1 answer
  • Someone please help ASAP will brainlist
    9·2 answers
  • How to install an older version of prettier on yarn
    9·1 answer
  • A local pizza shop is selling a large pizza for $9.99. Given the number of pizzas to order as input, output the subtotal for the
    12·1 answer
  • Print("Weight on Earth?")
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!