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

Trupti Patil said:   1 decade ago
Function written inside block is called local function & used only within that block. Function declared before main program starts below the header files is called global function.

Scope of local function is only within that part of the program it can not be access in other function.

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

Rem = 0.

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

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

Anjali said:   1 decade ago
What is return 0?

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?

Ajith said:   1 decade ago
What is REM?

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

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

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


Post your comments here:

Your comments will be displayed after verification.