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 ?
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 1 of 15.
Shan said:
1 decade ago
What is the work of the fmod?
Nidhi said:
1 decade ago
The answer could be option A (i.e) rem = 3.14 % 2.1 ?
Chandra said:
1 decade ago
% operator represents Reminder in C Language
But it is not possible for floating point operations.So,the Answer would be option (d).
(d)Remainder cannot be obtain in floating point division.
But it is not possible for floating point operations.So,the Answer would be option (d).
(d)Remainder cannot be obtain in floating point division.
Nagendran said:
1 decade ago
Good explanation
JAY said:
1 decade ago
I think chandra also correct in the sence of maths.
Arvind said:
1 decade ago
%(modulo) operator is in arithmatic
fmod is the c function
fmod is the c function
Swathy said:
1 decade ago
Yes. For int only we can use mod for float we should use fmod the answer should be c only for this problem.
(1)
Sandeep said:
1 decade ago
What Swathy said would be the exact explanation.
Renuka said:
1 decade ago
Yes fmod is the correct ans as in for floating division.
(1)
Mahesh said:
1 decade ago
What is use of fmod() function ?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers