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 6 of 15.
Raku said:
1 decade ago
@Nayarana it is not possible.
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);
?
Rajasekar said:
1 decade ago
Its very nice.
Dipak said:
1 decade ago
I think, an % sign also can done it !
Rohini palanichamy said:
1 decade ago
@Ajinkya , see @pramkumar's explanation , you will clear.
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);
}
Sundar said:
1 decade ago
@Sreedhar
Step by step process:
a = XXX * 10
a = ABC - XYZ * 10
a = 20 - 10* 10
a = 20 - 100
a = -80
Step by step process:
a = XXX * 10
a = ABC - XYZ * 10
a = 20 - 10* 10
a = 20 - 100
a = -80
Amar said:
1 decade ago
Thanks for your suggestions.
Krishna said:
1 decade ago
modf(x, y) is used to split the float point in to the intpart and factpart.
Ex: 3.13=3.00+0.13
fmod(x,y) is used to find the remainder in floating points.
Ex: fmod(3.14,2.1)
Ex: 3.13=3.00+0.13
fmod(x,y) is used to find the remainder in floating points.
Ex: fmod(3.14,2.1)
Bharadwaj said:
1 decade ago
Please clarify my doubt.
What is the meaning of "External declaration and Where is use" ?
What is the meaning of "External declaration and Where is use" ?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers