Question: Write a program to ask the user to enter a number and display its square root. If the user enters a negative number, your program
- Write a program to ask the user to enter a number and display its square root. If the user enters a negative number, your program should ask the user to re-enter the number again repeatedly until the user finally enters a zero or a positive number. Then your program shall display its square root. You may assume that the user only enters a number, not letters or symbols. Therefore there is no input failure. (30%)
Hint: (1) Use a while loop or a do-while loop for the repetition.
(2) The square root function sqrt() is defined in cmath.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
