C Programming - Floating Point Issues - Discussion
Discussion Forum : Floating Point Issues - General Questions (Q.No. 10)
10.
Which of the following statement obtains the remainder on dividing 5.5 by 1.3 ?
Answer: Option
Explanation:
fmod(x,y) - Calculates x modulo y, the remainder of x/y.
This function is the same as the modulus operator. But fmod() performs floating point divisions.
Example:
#include <stdio.h>
#include <math.h>
int main ()
{
printf ("fmod of 5.5 by 1.3 is %lf\n", fmod (5.5, 1.3) );
return 0;
}
Output:
fmod of 5.5 by 1.3 is 0.300000
Discussion:
10 comments Page 1 of 1.
Devendra Pandey said:
10 years ago
According to me.
Rem = (x%y) ___is used to calculate remainder of integer numbers, but it is not applicable for float numbers.
So here we use.
Rem = fmod (x, y) ___where 'fmod' comes in 'math.h' library.
So here option (A) is wrong & option (C) is correct.
Rem = (x%y) ___is used to calculate remainder of integer numbers, but it is not applicable for float numbers.
So here we use.
Rem = fmod (x, y) ___where 'fmod' comes in 'math.h' library.
So here option (A) is wrong & option (C) is correct.
A.Srikanth said:
8 years ago
modf() function is used to calculate integer part and fractional part of a double or float value.
fmod() function is used to calculate modulo division for float and double values since % operator doesn't work for float and double values.
fmod() function is used to calculate modulo division for float and double values since % operator doesn't work for float and double values.
(1)
Tushar said:
9 years ago
fmod() is the library function defined in math.h file.
To calculate remainder of floating point numbers.
Syntax : fmod(x,y);
To calculate remainder of floating point numbers.
Syntax : fmod(x,y);
Pinku said:
1 decade ago
What is the error in 5.5% 1.3 if fmod is same as modulus operator?
Mahesh said:
1 decade ago
What is the diffrence between modf() and fmod() functions in C?
(1)
Mousumi said:
10 years ago
What's the use of 'math.h' and why should we use?
Gopi said:
1 decade ago
How is it correct may be modf() and fmod()?
Vindhya said:
1 decade ago
Explain fmod and modf with simple example?
Sandy said:
1 decade ago
What is the function for long division?
Mamta Kumari said:
1 decade ago
Why option [A] is wrong?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers