Skip to main content
Logo image

Section 18.10 Practice Your Rounding!

Activity 18.5.

Write a function roundToTwo() that rounds off a floating point value to two decimal places. For example, 5.567 should be rounded to 5.67 and 5.534 should become 5.53.
The prototype for this function should be
double roundToTwo(double);
Please complete the code below.
Challenge: Round to “n” decimal places (you’ll have to pass an additional integer n to the function).

admin.....open in new window

When you are done, please paste your code into the code submission box below: