Pre-Lab - Lab (17)



Answer the following questions in writing.

1) Suppose you are writing a program that performs many different arithmetic operations.  Some of these operations are not defined in some specific situations.  For example, division by zero and taking the square root of a negative value are two operations that are not defined.  Which one of these two methods would you prefer:
        A) write the program to perform the basics and once done, add the part that takes care of special situations, or
        B) write the program and as you write it include the specific situations.

Explain why your choice is better than the other.
 
 
 

2) Write a program that asks users to input a number and then displays the square root of that number.  Create a function that displays a warning message when you attempt to take the square root of a negative value.
 
 
 
 

3) Suppose you are writing a program that at some point performs division.  How would you handle cases where you may divide by 0?