Ask your own question, for FREE!
Computer Science 20 Online
OpenStudy (anonymous):

what is the use of floor function in c??

OpenStudy (anonymous):

The floor() function can be used in the C++ language to make the round of the given specified value. The floor() function can returns the largest value that can be an integral and that can not be greater than y. The following can be the general syntax of the floor() function of the C++ language : Code: float floor ( float y ); long double floor ( long double y );

OpenStudy (anonymous):

floor function returns you the floor value of a decimal number ex: 9.45 floor function will return 9 2.78 floor function will return 2

OpenStudy (anonymous):

Also note that floor(-2.78) = -3

OpenStudy (jagatuba):

Good catch drjefferson. Floor always rounds a decimal number down to the nearest integer. It is very easy to get stuck in the thinking that floor just drops the decimal, but when dealing with negative decimals this is not the case.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!