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 4 of 15.
Deepak sharma said:
1 decade ago
That is right answer because the given expression is in the floating type formate so witought fmod() is use that not give right answer so fmod() is used.
Velmani said:
1 decade ago
% (%d)is used for only integer datatype. % is does not used for float datatype. So if you need mod in deciamal number then you can use fmod(%f) function.
Vikas said:
9 years ago
#include<stdio.h>
#includ<conio.h>
void main()
clrscr();
{
float a,b,c;
c=a%b;
getch();
}
Please explain the program with its output.
#includ<conio.h>
void main()
clrscr();
{
float a,b,c;
c=a%b;
getch();
}
Please explain the program with its output.
Nagesh said:
1 decade ago
Your answer may be depends on the Statement i.e. both % operator as well as fmod() used for taking Reminder %op for integer and fmod() for float.
Vani said:
1 decade ago
#include<stdio.h>
main()
{
printf("%d",printf("ABC\"));
}
Can anyone please explain how it gives o/p as ABC4 ?
main()
{
printf("%d",printf("ABC\"));
}
Can anyone please explain how it gives o/p as ABC4 ?
Amer patel said:
10 years ago
If you use % for fining remainder it will give you an integer value.
But the fmmod() function gives you remainder in floating point value.
But the fmmod() function gives you remainder in floating point value.
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.
Rey said:
10 years ago
What is REM?
And I also need some information about what is the difference between.
Rem = 3.14% 2.1; and rem = fmod (3.14, 2.1);
And I also need some information about what is the difference between.
Rem = 3.14% 2.1; and rem = fmod (3.14, 2.1);
Hemanth Kumar K said:
1 decade ago
fmod() function with values of floating type is the only operator which can be used to obtain the remainder for floating numbers.
Shubham choudhary said:
1 decade ago
Why did ansi form fmod() operator when % already was. It could be used for both the purpose. Integers as well as float?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers