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]
2 years ago
12

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

Computers and Technology
1 answer:
vazorg [7]2 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
What is operating system​
iren [92.7K]

Answer:

It's simply a software that runs a computer's basic tasks, or functions, such as scheduling, running applications, and controlling peripherals.

3 0
2 years ago
Read 2 more answers
When you gather primary or secondary data, what part of the market information management process are you participating in?
Umnica [9.8K]

Answer:

Heyyyooo!

The answer is market research.

Hope this helps!

Explanation:

Market research is the way toward gathering, analyzing and interpreting data about a market, about an item or administration to be offered available to be purchased in that advertise, and about the past, present and potential clients for the item or administration; examination into the attributes, ways of managing money, area and necessities of your business' objective market, the industry all in all, and the specific contenders you confront.  

3 0
2 years ago
Fifty-three percent of U.S households have a personal computer. In a random sample of 250 households, what is the probability th
aleksley [76]

Answer:

The correct Answer is 0.0571

Explanation:

53% of U.S. households have a PCs.

So, P(Having personal computer) = p = 0.53

Sample size(n) = 250

np(1-p) = 250 * 0.53 * (1 - 0.53) = 62.275 > 10

So, we can just estimate binomial distribution to normal distribution

Mean of proportion(p) = 0.53

Standard error of proportion(SE) =  \sqrt{\frac{p(1-p)}{n} } = \sqrt{\frac{0.53(1-0.53)}{250} } = 0.0316

For x = 120, sample proportion(p) = \frac{x}{n} = \frac{120}{250} = 0.48

So, likelihood that fewer than 120 have a PC

= P(x < 120)

= P(  p^​  < 0.48 )

= P(z < \frac{0.48-0.53}{0.0316}​)      (z=\frac{p^-p}{SE}​)  

= P(z < -1.58)

= 0.0571      ( From normal table )

6 0
3 years ago
The procedure by which a process's state is saved before being swapped out of the cpu, then us restored to the state when the pr
belka [17]

The procedure is known as<u> context switching</u>.

In the field of computers, context switching can be described as a procedure in which a process is stored so that it can be executed at a later point. Such a procedure allows multitasking operations easier. A simple CPU can be utilized for multiple processes.

After a task is done, it can be swapped out of the CPU and can be restored later. By using context switching, more space can be provided on a CPU as freeing from one process will make space for the other.

When switching a process, the status of the older running process is saved on the CPU as registers.

Context switch makes it feasible to share one CPU for multiple procedures hence reducing the concerns that arise from using additional processors.

To learn more about context switch, click here,

brainly.com/question/21685677

#SPJ4

3 0
1 year ago
Under which tab can you find the options for reusing slides from other presentations
MrRissso [65]
U could first highlight text, right click then copy, and then Ctrl + v. You could find Ctrl (or control) under the shift button to your left
I hope this helped:D
5 0
2 years ago
Other questions:
  • Para saan po yung points dito?
    15·1 answer
  • Enzo formed a study group for an upcoming geography test. To start off each session, they go over past notes and look at maps. T
    14·1 answer
  • Describe some advantages of a 64-bit versus 32-bit version of windows.
    9·1 answer
  • Oxygen-18 has an atomic number of 8. How many neutrons are in this isotope?
    7·1 answer
  • What is the quickest way to change the format of a table?
    8·1 answer
  • What are some options available in the Spelling and Grammar Checker? Check all that apply. Change and Change All Redo and Repeat
    15·2 answers
  • Which computer was part of the first generation of computers?
    14·2 answers
  • Adding Page Numbers in the Footer
    15·1 answer
  • I need help pls help me
    8·1 answer
  • In what year was the first permanent photographic image created?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!