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.
Shubhangi said:
2 years ago
@All.
The % modulus operator gives a remainder of only int and not applicable for float.
The % modulus operator gives a remainder of only int and not applicable for float.
(26)
Ayesha said:
2 years ago
Option D is right because the floating point is not applicable for %.
(10)
Dipak said:
5 years ago
@All.
We can't apply % sign on float.
We can't apply % sign on float.
(7)
Renu said:
6 years ago
I don't understand this answer please explain me simply.
(5)
Bibhas Kumar sahu said:
6 years ago
I don't understand this answer please explain me simply.
(4)
Krishna said:
6 years ago
Why option C is more relevant?
(3)
Peter Omondi said:
5 years ago
Well understood. Thanks all for explaining.
(3)
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)
Renuka said:
1 decade ago
Yes fmod is the correct ans as in for floating division.
(1)
Silambu said:
7 years ago
No @Keerthi.
The floating point remainder cannot be obtained by modulo operator.
The floating point remainder cannot be obtained by modulo operator.
(1)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers