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 2 of 15.
Swathy said:
2 decades 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:
2 decades ago
Yes fmod is the correct ans as in for floating division.
(1)
Sugandha Singh said:
1 decade ago
It means % operator is use when we are doing integer division to get the remainder?
(1)
Md imran khan said:
1 decade ago
Which function is called global and local function? Can anybody help me?
(1)
Vidya said:
10 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.
(1)
Banu said:
9 years ago
What is the correct answer for this question?
(1)
Tanushi said:
9 years ago
Please explain how this work?
(1)
Subrat said:
9 years ago
@Dinesh Kumar.
#include<stdio.h>
int main()
{
int a=1;
printf("%d %d %d",a,a++,++a);
return 0;
}
Output : 3 2 3.
But logically 3 2 2.
Can any explain how 3 2 3 comes?
Your logic is true,function data passing is from right to left. So first ++a execute then a++,then a.
But the current value of a will be substitute in pre-increment operator always.
So the output will be 3 2 3.
#include<stdio.h>
int main()
{
int a=1;
printf("%d %d %d",a,a++,++a);
return 0;
}
Output : 3 2 3.
But logically 3 2 2.
Can any explain how 3 2 3 comes?
Your logic is true,function data passing is from right to left. So first ++a execute then a++,then a.
But the current value of a will be substitute in pre-increment operator always.
So the output will be 3 2 3.
(1)
Silambu said:
8 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)
Bhuvana said:
7 years ago
Option C is correct. Thanks
(1)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers