Question: Write a C++ program that reads a positive integer entered by an interactive user and then prints out all the positive divisors of that integer

Write a C++ program that reads a positive integer entered by an interactive user and then prints out all the positive divisors of that integer in a column and in decreasing order. The program should allow the user to repeat this process as many times as the user likes. Initially, the program should inform the user about how the program will behave.

Then the program should prompt the user for each integer that the user wishes to enter. The program may be terminated in any of two ways. One way is to have the program halt if the user enters an integer that's negative or zero. In this case the user should be reminded with each prompt that the program can be terminated in that way.

Alternatively, after an integer has been entered and the divisors have been printed, the program can ask the user whether he/she wishes to enter another integer. In this case, when the user accidentally enters a zero or negative integer to have its divisors calculated, the program should inform the user that the input is unacceptable and should allow the user to try again (and again!).

The program should use a function

1) void divisors(int x, int && y)

Where the x is the integer entered by the user and the y is a pointer to an array of integers. The computation of the divisors should be done by this function.

2) void printdivisors( int &&y)

Where the y is the array of the divisors, this function should print the divisors.

You can use as many other functions you want in this program.

Your program, should include detailed comments and you should submit the program as a .cpp file.

//C++, write in the comments why would you type this please.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!