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 8 of 15.

JCoder said:   1 decade ago
fmode() is the lib function, returns the reminder of floating point.

Md imran khan said:   1 decade ago
Why array index is always start with zero? Please reply any body?

Jagadeesh kumar said:   1 decade ago
It's nothing but difference between numerator and denominator.

Vijay said:   1 decade ago
What is the difference between %, mod(), fmod() and modf()?

Sagar said:   1 decade ago
What is the difference between %, mod(), fmod() and modf()?

Arvind said:   1 decade ago
%(modulo) operator is in arithmatic
fmod is the c function

Kavita.C.K said:   1 decade ago
What is the difference between %, mod(), fmod()and modf()?

Sivakumar said:   1 decade ago
I want to know clear difference between fmod() and modf().

Janani said:   1 decade ago
What is the difference between an identifier and variable?

Rohini palanichamy said:   1 decade ago
@Ajinkya , see @pramkumar's explanation , you will clear.


Post your comments here:

Your comments will be displayed after verification.