Write a function to compute the square-root of a given number. If the given number is negative, your function should give an error message.

By: Prof. Dr. Fazal Rehman | Last updated: February 3, 2024

Write a function to compute the square-root of a given number. If the given number is negative, your function should give an error message.

Output for Positive number

Please Enter a Number to Calculate the square root of the given number 4
The square root of 4 is 2

Output for Negative number

Please Enter a Number to Calculate the square root of the given number -6
Error: Sorry, cannot compute square root of a negative Number

All Copyrights Reserved 2025 Reserved by T4Tutorials