Write a C++ program that reads a positive integer user input number n, asserts the value...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a C++ program that reads a positive integer user input number n, asserts the value of n is positive, and then generates n random integers in the range [1, 100] each. Your program must also print each generated random number, the factors of each of the generated random number, and finally report which of the random numbers has the largest number of factors. You are required to seed the random number generator in your program. Moreover you are required to provide all include directives needed for your program to work without any syntax, runtime, or semantic errors. Please note that the factors of a positive integer number m are defined as those integers in the range [1, m] that divide m. For example, the factors of 6 are 1, 2, 3, and 6. The following sample run output is provided in order to help you understand the problem better. Sample Run Output Enter a positive integer value of n: 8 3 5 15 89 2 3 5 6 10 15 30 2 29 58 The generated random number is 15 Its factors are 1 The generated random number is 89 Its factors are 1 The generated random number is 30 Its factors are 1 The generated random number is 58 Its factors are 1 The ger random number is 28 Its factors are 1 The generated random number is 60 Its factors are 1 The generated random number is 28 Its factors are 1 The generated random number is 62 Its factors are 1 2 31 62 2 4 7 14 28 2 3 4 5 6 10 12 15 20 30 60 2 4 7 14 28 The random number with the largest number of factors is 60 Press any key to continue... Write a C++ program that reads a positive integer user input number n, asserts the value of n is positive, and then generates n random integers in the range [1, 100] each. Your program must also print each generated random number, the factors of each of the generated random number, and finally report which of the random numbers has the largest number of factors. You are required to seed the random number generator in your program. Moreover you are required to provide all include directives needed for your program to work without any syntax, runtime, or semantic errors. Please note that the factors of a positive integer number m are defined as those integers in the range [1, m] that divide m. For example, the factors of 6 are 1, 2, 3, and 6. The following sample run output is provided in order to help you understand the problem better. Sample Run Output Enter a positive integer value of n: 8 3 5 15 89 2 3 5 6 10 15 30 2 29 58 The generated random number is 15 Its factors are 1 The generated random number is 89 Its factors are 1 The generated random number is 30 Its factors are 1 The generated random number is 58 Its factors are 1 The ger random number is 28 Its factors are 1 The generated random number is 60 Its factors are 1 The generated random number is 28 Its factors are 1 The generated random number is 62 Its factors are 1 2 31 62 2 4 7 14 28 2 3 4 5 6 10 12 15 20 30 60 2 4 7 14 28 The random number with the largest number of factors is 60 Press any key to continue...
Expert Answer:
Answer rating: 100% (QA)
Program include include include using namespace std int main int n maxfactors 0 maxnumber 0 srandtim... View the full answer
Related Book For
Discrete and Combinatorial Mathematics An Applied Introduction
ISBN: 978-0201726343
5th edition
Authors: Ralph P. Grimaldi
Posted Date:
Students also viewed these programming questions
-
A company manufactures and retails clothing. You are required to group the costs which are listed below and numbered (1)-(20) into the following classifications (each cost is intended to belong to...
-
Without calculating, determine whether the value of nPr is greater than the value of nCr for the values of n and r given in the table. Complete the table using yes (Y) or no (N). Is the value of nPr...
-
You are to write a C program that will read from a file, one or more sets of x,y coordinates. Each set of coordinates is part of a Cartesian system. A Cartesian coordinate system is a system that...
-
A company has 10,000 employees. Each employee is entitled to twenty days of paid holiday per calendar year. Up to five days of this entitlement may be carried forward and taken in the following year...
-
Describe what needs to be done to manage risk on a project. When should this be done? How can a risk assessment matrix help in this process?
-
Select two consecutive days (48 hours) where you will unplug from technology and not use the following electronic means for leisure: cell phones, television, internet, ipods, mp3 players, game...
-
Differentiate between Type I and Type II errors.
-
The T-accounts of Morris Farm Equipment Repair follow as of May 31, 2016. Prepare Morris Farm Equipment Repairs trial balance as of May 31, 2016. ASSETS LIABILITIES EQUITY Contributed Capital +...
-
How do cultural nuances impact collaborative efforts in multinational corporations? Explain with example
-
Cherry Cotta makes custom ordered clay pots for residential gardens. Below is cost information regarding its latest job. a. Materials were purchased on account. $18,996 purchased b. A materials...
-
Extra credit: Who sued the production of Straight Outta Compton for a false portrayal of him? You are going to have to look this one up.
-
Define depreciation from a tax viewpoint. Explain why it is said to offer tax shelterpotential. What real estate investments provide this benefit? Explain.
-
Which of the following is false? a. Under GAAP, current liabilities are presented before non-current liabilities. b. Under GAAP, an item is a current liability if it will be paid within the next 12...
-
Which one of the following cannot be a true statement about an object: (a) It has zero velocity and a nonzero acceleration; (b) it has velocity in the x-direction and acceleration in the y-direction;...
-
Assume you have inherited a large sum of money and wish to use part of it to make a real estate investment. a. Would you invest in income property or speculative property? Why? Describe the key...
-
Tianzi Coffee reported net sales of HK\($1,800,000,\) net income of HK\($540,000,\) beginning total assets of HK\($2,000,000,\) and ending total assets of HK\($3,000,000.\) What was the companys...
-
Blake's wealth is w= $5,000 (in thousands of dollars), and his utility function over his wealth is U(w) = 2 In (w). He is approached by a hedge fund manager who offers him a risky investment of...
-
If the annual fixed costs are 54,000 dinars, the occupation expense represents 20%, the contribution margin is 25%, and the unit selling price is 40 dinars. Required: Calculate the closing point of...
-
For each of the networks in Fig. 15.8 express the output in terms of the Boolean variables x, y or their complements. Then use the expression for the output to simplify the given network. xy
-
Implement the half-adder of Fig. 15.3 using only (a) NAND gates; (b) NOR gates. x ty (x+yxy) xy The half-adder
-
Let G = (V, E) be a loop-free undirected ft-regular graph with |V| 2n + 2. Prove that (the complement of G) has a Hamilton cycle.
-
Example In January 2004, a Mars Exploration Rover touched down on the surface of Mars and rolled out for exploration ( Figure
-
Does the snowflake have rotational symmetry in Figure 1.6? If yes, describe the ways in which the flake can be rotated without changing its appearance. Does it have reflection symmetry? If yes,...
-
A battery-operated wall clock no longer keeps timeneither hand moves. Develop a hypothesis explaining why it fails to work, and then make a prediction that permits you to test your hypothesis....
Study smarter with the SolutionInn App