Write the C++ language statements to ask a user to enter a number within the range of 0 to 100 (0 and 100 are valid inputs). When the value is not valid, you should prompt the user to enter another value. (The user may enter many invalid numbers, so you must use loop). Only after the user enters a valid number should you display the message “Good” and the value of the number. |
#include <iostream> using namespace std; int main() { int n; cout<<"Enter a number within the range of 0 to 100: "; cin>>n; while(n<0 || n>100){ cout<<"Enter a number within the range of 0 to 100: "; cin>>n; } cout<<"Good "<<n<<endl; return 0; }
Get Answers For Free
Most questions answered within 1 hours.