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 3 of 15.
Subrat said:
8 years ago
#include <stdio.h>
#include <math.h>
int main ()
{
float 3.13.2.1;
float R;
R=fmod(3.14,2.1);
printf ("The remainder is:",R);
scanf("%f",R);
return 0;
}
It will show error, because you write
float 3.13.2.
#include <math.h>
int main ()
{
float 3.13.2.1;
float R;
R=fmod(3.14,2.1);
printf ("The remainder is:",R);
scanf("%f",R);
return 0;
}
It will show error, because you write
float 3.13.2.
Tanushi said:
8 years ago
Please explain how this work?
Banu said:
8 years ago
What is the correct answer for this question?
Afsia said:
8 years ago
Difference between modf and fmod is fmod gives remainder when x divided y. Fmod stands for floating modulus while in modf the parts spilt in two modfvalue into an integer and a fractional part. The fraction is returned by the modf function and the integer part is stored in the iptr variable. Iptr means pointer to the variable stored in an integer.
Bhargav dave said:
8 years ago
Hello, I am new on this.
Can anyone explain to me how this program work?
Can anyone explain to me how this program work?
Amarjeet said:
8 years ago
I think the answer A is correct.
Kennedy muriuki said:
8 years ago
I support answer C, fmod should be used in float where we need decimal points.
Renu said:
8 years ago
Modulus & division are different.
Keerthana said:
8 years ago
% - it doesn't support real numbers that is a float and double.
fmod is an inbuilt function that finds the remainder of real number.
fmod is an inbuilt function that finds the remainder of real number.
Vidya said:
9 years ago
Usually % (modules) operator not for floating point numbers, so in c fmod is inbuilt function that will use to get the reminder of the floating point number. Answer is C.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers