Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Language%20in%20C%20Interview%20Questions%20and%20Answers

Question: Can we get the remainder of a floating point division ?

Answer: Yes. Although the % operator fails to work on float numbers we can still get the remainder of floating point division by using a function fmod( ). The fmod( ) function divides the two float numbers passed to it as parameters and returns the remainder as a floating-point value. Following program shows fmod( ) function at work.

#include <math.h>

main( )
{
printf ( "%f", fmod ( 5.15, 3.0 ) ) ;
}

The above code snippet would give the output as 2.150000.
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook