Question
How can I modify my code (below) to meet the requirements that follows: Change the return type of your squareRoot() function to void, so that
How can I modify my code (below) to meet the requirements that follows:
Change the return type of your squareRoot() function to void, so that it cant return anything. We want the same behaviour as earlier, but instead of using the return value, we will now let the result be set to the value -1 if we call the function with a negative number. The reason this works is that the square root can never be negative. Since squareRoot() no longer returns a value, and we want the program to behave exactly like before, you will also have to do modifications to main() so that it works just like before, but using the result instead of the return value from squareRoot() to determine the printout. Since the program is expected to work like before from the users perspective, no example run is needed.
My code:
#include
{ printf("The square root of the entered number is: %f", squareRootResult); } else { printf("It is not possible to calculate the square root of a negative number"); } return 0; }
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