Write a program that repeatedly prompts for a positive integer and prints the fa
ID: 3651595 • Letter: W
Question
Write a program that repeatedly prompts for a positive integer and prints the factors ofthe integer. If the integer is prime, then the program also prints that the integer is prime.
The program repeats until 0 is entered as the integer, and then it halts.
Program factors.cpp:
(a) Prompt and read in an integer.
(b) If the integer is negative, print an error message and repeat step (a).
(c) If the integer is 0, exit the program.
(d) If the integer is greater than 0, report all the factors of the integer in increasing
order. An integer x is a factor of y if y mod x equals 0. Note that 1 and y are
always (trivial) factors of y.
(e) An integer y is prime if y has exactly two factors, 1 and y. (Integer 1 has only
one factor so we don
Explanation / Answer
#include using namespace std; void report(int n) { coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.