Please help i am in C one so no advanced methods please Roun
Please help i am in C++ one so no advanced methods please
(Rounding Numbers) Function floor can be used to round a number to a specific decimal
 place. The statement
 y = floor( x * 10 + .5 ) / 10;
 rounds x to the tenths position (the first position to the right of the decimal point). The statement
 y = floor( x * 100 + .5 ) / 100;
 rounds x to the hundredths position (the second position to the right of the decimal point). Write
 a program that defines four functions to round a number x in various ways:
 a) roundToInteger( number )
 b) roundToTenths( number )
 c) roundToHundredths( number )
 d) roundToThousandths( number )
 For each value read, your program should print the original value, the number rounded to the
 nearest integer, the number rounded to the nearest tenth, the number rounded to the nearest hundredth
 and the number rounded to the nearest thousandth.
Solution
#include<iostream>
 #include<cmath>
 using namespace std;
int main()
 {
    int roundToInteger( double number );
 double roundToTenths( double number );
 double roundToHundredths(double number );
 double roundToThousandths(double number );
   double y = 12.42844567788990090909;
   
    cout<<\"Rounding to nearest integer = \"<<roundToInteger(y)<<endl;
    cout<<\"Rounding to the tenths position = \"<<roundToTenths(y)<<endl;
    cout<<\"Rounding to the hundredths position = \"<<roundToHundredths(y)<<endl;
    cout<<\"Rounding to the thousandths position = \"<<roundToThousandths(y)<<endl;
   
 }
 int roundToInteger( double x )
 {
    return floor( x + .5 );
 };
 double roundToTenths( double x )
 {
    double y = floor( x * 10 + .5 ) / 10;
    return y;
 }
 double roundToHundredths(double x )
 {
    double y = floor( x * 100 + .5 ) / 100;
    return y;
 }
 double roundToThousandths( double x )
 {
    double y = floor( x * 1000 + .5 ) / 1000;
    return y;
 }

