Question: Write a complete C++ program that prompts user to enter a positive number, if the number is invalid prompt user to enter again, give a

Write a complete C++ program that prompts user to enter a positive number, if the number is invalid prompt user to enter again, give a maximum of 3 attempts to enter a positive number, terminate the program if user enters a bad input for all 3 attempts. It then prints all nonzero even digits in this input number backwards starting from last digit on its right. (second extra credit point: prints all factors (excluding 1 and itself) of this input, hint: check all possible factors from 2 to input-1, for each number in the range that's a factor of input, print it out) Sample1: user input is in italic Please enter a positive number: -2 Bad input. Please enter a positive number: -1 Bad input. Please enter a positive number: 205 Nonzero even digit in reverse: 2
Factors: 5 41 Sample2: user input is in italic Please enter a positive number: -2 Bad input. Please enter a positive number: -1 Bad input. Please enter a positive number: 0 3 wrong inputs, bye! Sample3: user input is in italic Please enter a positive number: 98765432 Nonzero even digit in reverse: 2468

Factors: 2 4 8 37 74 148 296 333667 667334 1334668 2669336 12345679 24691358 49382716

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!