Answered step by step
Verified Expert Solution
Link Copied!

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

  1. 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

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions

Question

A single line JavaScript Comment begins with: \ \ True False

Answered: 1 week ago