C Programming - Control Instructions - Discussion

3. 

The modulus operator cannot be used with a long double.

[A]. True
[B]. False

Answer: Option A

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 or long double divisions.


Ruby said: (Sep 20, 2012)  
example for fmod:
#include<stdio.h>
#include<math.h>
int main()
{
float x=10.10,y=2.0, z;
z=fmod(x,y);
printf("%f", z);

return 0;
}

Snehal said: (Jul 25, 2013)  
Is this means that modulus operator works ONLY on integers?

Darshan Patel said: (Dec 7, 2015)  
It is not possible to perform modulo operator with float and double.

Pranouti said: (Jun 7, 2016)  
If I am right, fmod(x,y) is a function. And the question is "The modulus operator cannot be used with a long double". Then the answer should be (B). Because we can not use modulus operator with float or double. For this, we use the function in math.h header file which is fmod().

I think the answer is B.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.