Write a program that prompts the user to enter a positive integer and then uses this criterion to determine whether the number is divisible by 11.
Only positive integers are valid input. Negative integers as input should produce an error message. Use zero (0) as your sentinel value.
1
Expert's answer
2014-10-31T11:21:38-0400
using namespace std; int main() { int current_choice; while(true) { cout << "Enter and positive integer or zero to exit: "; cin >> current_choice; if (current_choice == 0) { cout << "End of program.\n"; break; } if (current_choice < 0) { cout << "Error! Please enter positive number or 0 to exit.\n"; } if (current_choice > 0) { if (current_choice % 11 == 0) cout << "Your number is divisible by 11!\n"; else cout << "Your number isn't divisible by 11!\n"; } }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment