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

Vikas said:   1 decade ago
What is the use of return 0 there?

Prasann said:   1 decade ago
For floating point operator % cannot be used. Only operator/can be used.

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

Sivaraman said:   1 decade ago
It's really not understand me, please briefly explain it for modf() and fmod().

Ajith said:   1 decade ago
What is REM?

Prtk15 said:   1 decade ago
There is a new data-type which can take as values natural numbers between (and including) 0 and 25. How many minimum bits are required to store this data-type?

What will be its answer? Can anybody help me?

Anjali said:   1 decade ago
What is return 0?

Md imran khan said:   1 decade ago
Which function is called global and local function? Can anybody help me?

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

Mani said:   1 decade ago
2)16(8
16
------------
0

Rem = 0.


Post your comments here:

Your comments will be displayed after verification.