C Programming - Control Instructions - Discussion

Discussion Forum : Control Instructions - True / False Questions (Q.No. 3)
3.
The modulus operator cannot be used with a long double.
True
False
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.

Discussion:
4 comments Page 1 of 1.

Pranouti said:   8 years ago
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.

Darshan patel said:   8 years ago
It is not possible to perform modulo operator with float and double.

Is this means that modulus operator works ONLY on integers?

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;
}