Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Write a program valid.cpp, which asks the user to input an integer in the range 0 < n < 100 . If the number is

Write a program valid.cpp, which asks the user to input an integer in the range 0 < n < 100. If the number is out of range, the program should keep asking to re-enter until a valid number is input.

After a valid value is obtained, print this number n squared.

Example

$ ./valid Please enter an integer: -10 Please re-enter: 1200 Please re-enter: 100 Please re-enter: 7 Number squared is 49 

Hint: You can use a while or do ... while loop.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions