if this can round to an int....
int x = floor( your_float_or_double + 0.5 );
then it can be made to work for a float something like....
float x = floor( 100*(your_float_or_double + 0.5) ) / 100.0;
notice how we move the decimal point two places by multiplying with 100 so that floor can find an int then dividing result by 100 gives decimal to 2 decimal places. Thats what u want isnt it.See it wasnt hard. You were almost given the answer by your teacher and i tried not to give it to u but instead make you think for yourself but as you couldn't work it out I have shown you the guts.
Firstly wrap in a function.
Secondly a bit harder, can you make a function that will round to a passed number of decimal points.Its not too hard.