Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started