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 8 of 15.
Asif sadrul said:
1 decade ago
@Ayapan.
Use %f instead of %d.
Use %f instead of %d.
Grub said:
1 decade ago
fmod() outdated and is not supported by gcc compilers hence answer is(D).
Prashant said:
1 decade ago
% in c language represents remainder after division,
The number can be of integer or float but in global declaration reminder should be declared in float irrespective of declared variables.
The number can be of integer or float but in global declaration reminder should be declared in float irrespective of declared variables.
HAMIR BHARWAD said:
1 decade ago
fmod(x,y) function is used to get remainder of floating point divisions.
Vignesh said:
1 decade ago
What is the work of fmod?
Manjunath K said:
1 decade ago
Hai friends, mod() is used for the integer division to get remainder. Where as fmod() is used to get floating point remainder. We find both mod() and fmod()in math.h header file check it once.
Vinay said:
1 decade ago
What is the difference between modf and fmod?
Sangee said:
1 decade ago
Where we want to use #include<math.h>?
Aafreen said:
1 decade ago
What if 3.14 % 2? What to use?
Prithvi said:
1 decade ago
#include <stdio.h>
#include <math.h>
int main ()
{
int rem;
rem=3.14/2.1;
printf ("rem= %d\n", rem);
return 0;
}
0p:1.
#include <math.h>
int main ()
{
int rem;
rem=3.14/2.1;
printf ("rem= %d\n", rem);
return 0;
}
0p:1.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers