C Programming - Declarations and Initializations - Discussion

Discussion Forum : Declarations and Initializations - General Questions (Q.No. 1)
1.
Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ?
rem = 3.14 % 2.1;
rem = modf(3.14, 2.1);
rem = fmod(3.14, 2.1);
Remainder cannot be obtain in floating point division.
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 3.14/2.1 is %lf\n", fmod (3.14,2.1) );
  return 0;
}

Output:
fmod of 3.14/2.1 is 1.040000

Discussion:
141 comments Page 10 of 15.

Sandeep said:   1 decade ago
What Swathy said would be the exact explanation.

Ajay said:   1 decade ago
Do we have both modf() and fmod() in C language?

POOJA said:   1 decade ago
Difference between fmode(), modef() and mode()?

RAGU said:   1 decade ago
What is the difference between modf and fmod?

Chillu said:   1 decade ago
What is the difference between modf and fmod?

Vinay said:   1 decade ago
What is the difference between modf and fmod?

Banu said:   8 years ago
What is the correct answer for this question?

Sangee said:   1 decade ago
Where we want to use #include<math.h>?

Sakshi Deshmukh said:   1 year ago
Good answer, Thanks all for the explanation.
(1)

V!nu said:   1 decade ago
Nice explanation. I agree with that answer.


Post your comments here:

Your comments will be displayed after verification.