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 11 of 15.
Sreedhar said:
1 decade ago
Hi friends, please help me how give below program output -80 ?
#include<stdio.h>
#define ABC 20
#define XYZ 10
#define XXX ABC - XYZ
void main()
{
int a;
a = XXX * 10;
printf("%d\n", a);
}
#include<stdio.h>
#define ABC 20
#define XYZ 10
#define XXX ABC - XYZ
void main()
{
int a;
a = XXX * 10;
printf("%d\n", a);
}
Rohini palanichamy said:
1 decade ago
@Ajinkya , see @pramkumar's explanation , you will clear.
Dipak said:
1 decade ago
I think, an % sign also can done it !
Rajasekar said:
1 decade ago
Its very nice.
Ajinkya said:
1 decade ago
What is the difference between
rem = modf(3.14, 2.1);
rem = fmod(3.14, 2.1);
?
rem = modf(3.14, 2.1);
rem = fmod(3.14, 2.1);
?
Raku said:
1 decade ago
@Nayarana it is not possible.
Narayana reddy said:
1 decade ago
Is it possible take this in to EXE file to run other than c compiler please tell me.
Abhishek said:
1 decade ago
Thanks Anitha for your Answer.
Sagar said:
1 decade ago
What is the difference between %, mod(), fmod() and modf()?
Anitha 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.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers