Pre-Lab - Lab (2)

Before going through this lab, you need to read Chapter (2) of the text and try to answer the following questions.

1) What is the answer to the following arithmetic operations?

            a) (1/5) * 3
            b) (8/2) * 4
            c) (1.0/5.0) * 3

Is there any difference between a and c?

2) Convert the following mathematical expressions to C++ expressions:

            a) 4x
            b) (2x + y)/3y
            c) (2x - 3y)/(z -1)

3) Translate the following English statements to C++ expressions.

            a) Assign 2.7 to variable a
            c) Check to see if variable a is larger than 3.0
            d) Check to see if a is larger than 3 OR it is 0.
            e) Check to see if a is larger than or equal to 3 but less than 8
            f) Check to see if a is not 5
            g) Check to see if a is not larger than 9

4) Suppose age and ticket are both integer values, how do you state the following: "if you are 12 years or older the ticket is $16, otherwise the ticket is $8."

5) When the square root of b2 - 4ac is less than zero, how do you display the message "square root of a negative value is not defined"?