Write a program that generates all the factors of a number

Assignment Help C/C++ Programming
Reference no: EM13166748

Write a program that generates all the factors of a number entered by the user. For instance, the number 12 has the factors 2 * 2 * 3. This program has the following requirements:

A. The user must enter a positive integer. If the user enters something else, your program should output an error message and let the user enter a new value. Use a do/while loop to make sure the user input is successful.

B. The factors must be output in increasing order. The lowest factor your program should report is 2.

C. Your program should output 4 factors per line, each factor in a field of 10 characters. (Hint: the number of factors output determines when to output endl!)

D. You will need a while loop to report the factors. Here are some helpful hints:

1. If (a % b == 0) then a is a factor of b.

2. When you have found a factor, output the factor and then reduce the number you are working with by dividing the number by the factor... ie) b = b / a;

1. Design an algorithm in pseudocode to solve the problem. Make sure to include steps to get each input and to report the output. Include steps to deal with error cases as specified above.

2. Identify three test cases, one using a number with 4 factors, one using a negative number, and one using a number with more than 4 factors. For each of the three test cases show what inputs you will use and what your expected outputs should be.

3. Write the program to implement your algorithm. Test your program using your test cases.

Reference no: EM13166748

Questions Cloud

Write a small program to simulate a raffle : Write a small program to simulate a raffle (a gambling game) for a group with 100 members. You can simply identify each member with a no-duplicated ID numbers from 01 to 100. A number ticket with a positive 4-digits integer number will be randomly cr..
Which of the following has the smallest mass : Which of the following has the smallest mass?
The latest entry into the snack food industry : The latest entry into the snack food industry is a health-conscious offering named Hooks, Wheels, and Ladders. Each box mixes several flavors, such as ranch, cheddar, and salsa. The snack is designed to appeal to kids based on the snack shapes
Which one of the following compounds will be most soluble : Which one of the following compounds will be most soluble in water?
Write a program that generates all the factors of a number : Write a program that generates all the factors of a number entered by the user. For instance, the number 12 has the factors 2 * 2 * 3.
How many grams of total blood cholesterol : a typical person has 200 mg of cholesterol pr 100 ml of blood. If the total blood volume of an individual is 5 liters, how many grams of total blood cholesterol does the individual contain?
Calculate the flexed budget and the key variances : Calculate the flexed budget and the key variances between budgeted and actual results and reconcile the original budget and present the relationship between the budgeted and the actual profit for the month November
Compute the standard enthalpy change for this reaction : calculate the standard enthalpy change for this reaction using standard enthalpies of formation. general chemistry 10th edition ebbing and gammon
How the data block information is managed using fat : File X has 15 data blocks. The block addresses of the 15 blocks are 8, 9, 10, 11, 12, 13, 5, 4, 21, 22, 23, 24, 25, 26 and 27.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Make a class employee

Make a class EMPLOYEE with a name and salary. Make a class MANAGER inherit from EMPLOYEE. Add an instance field, named DEPARTMENT

  Converts the temperature f in farenheit to c in celsius

Write a program that converts the temperature F in Farenheit to C in Celsius using C = (F-32)*5/9. For ease of programming you can display the result in fractions.

  . write a segment of code that prints the number of elements

Assuming the array x has been defined as: int x[n]; for some n and that values have been assigned to all the elements. Write a segment of code that prints the number of elements between (but not including) the largest and smallest values in the array..

  Write a program that allows users to enter a dollar amount

Write a program that allows users to enter a dollar amount for their bank account balance at the beginning of the month. Then ask the user to enter a dollar amount for any number of checks written in a month, up to 50. Include an approriate sentinel ..

  Where s is any string

Write a function detab(s, stop), where s is any string, and stop is a positive integer called tabstop size. This function should return a string which is like s.

  Implement the guess the word

Implement  the ‘Guess the Word' game in an object-oriented manner

  Write a scanf statement to read in one number (int

1) Write a scanf statement to read in one number (int), and another statement to print out that number.

  Function alter with two parms passed by reference

Write a function alter with two parms passed by reference: x and y. alter changes the value of x to x+y and changes the value of y to x*y. Write a main function to read in two integers, print the two integers, call the function alter using the two..

  Test a program that prompts for the user

Write and test a program that prompts for the user to input a file name and uses two functions head() and tail() - head() displays the first 10 lines of a file

  The counter each time it''s clicked

Write a simple script that contains a button and a counter in a div. The button's event handler should increment the counter each time it's clicked.

  Write program in c to calculate diameter-compression load

Write a program in C to calculate diameter in centimeters of steel rod, an aluminum rod, and a copper rod, which can withstand a particular compression load.

  Initialize an array and fill the array with the gpa values.

Write a program in java that asks user input (using a loop) for name of 10 student and the corresponding grade point averages (GPAs). Initialize an array and fill the array with the GPA values.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd