Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

Numbers and Conversions (TCO 4) The following has one compile time bug. This bug only generates a warning in some compilers and would cause an...

2. Numbers and Conversions (TCO 4)

The following has one compile time bug. This bug only generates a warning in some compilers and would cause an exception during runtime. Visual Studio 2012 actually gives us an error at compile time. This is better, because you should never do the thing that causes this error. Fix the error and run the program. Compare the output to the code and answer the questions found after the code.

Here is the code.

Questions

1.    When storing a floating point number into an integer variable, does it truncate or round?

2.    When the floating point numbers were printed out at higher precision, they were not the same value as entered. Research this issue and explain why.

3.    The setprecision(12) command either sets the precision for 12 places after the decimal point or 12 digits total; select the right option for each case below.

a.    fixed [total/after the decimal point]

b.    scientific [total/after the decimal point]

c.    float [total/after the decimal point]

4.    Based on the results of taking the square root and then squaring again, what would you say about the accuracy of floating point arithmetic in C++?

5.    Dividing by zero in earlier compilers generates an error and an exception. What does Visual Studio 2012 produce as the result of dividing by zero?

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question