Question: Declare a Boolean variable named allValid. Then, read integer numVals from input representing the number of integers to be read next. Use a loop to

Declare a Boolean variable named allValid. Then, read integer numVals from input representing the number of integers to be read next. Use a loop to read the remaining integers from input. If all of the numVals integers are in the range -2000 to -1000 inclusive, assign allValid with true. Otherwise, assign allValid with false.
Code at the end of main() outputs "All valid" if allValid is true or "Has non-matching value(s)" if allValid is false.
Ex: If the input is:
2
-1500-985
then the output is:
Has non-matching value(s)C++

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!