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 13 of 15.
Gaurav said:
10 years ago
fmod() function is used to find out remainder of float numbers, not integer and normal operation like rem=12%7, it gives remainder only integer not float.
So option 1 is wrong and the correct is c.
I think you understand.
So option 1 is wrong and the correct is c.
I think you understand.
Karthi said:
9 years ago
What does the fmod represent here?
How could the answer be c but not a?
How could the answer be c but not a?
Vishal said:
9 years ago
C is the correct answer as % operator don't work on floating point numbers so A is incorrect.
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.
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.
Keerthana said:
9 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.
Renu said:
9 years ago
Modulus & division are different.
Kennedy muriuki said:
9 years ago
I support answer C, fmod should be used in float where we need decimal points.
Amarjeet said:
9 years ago
I think the answer A is correct.
Bhargav dave said:
9 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?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers