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 12 of 15.
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:
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.
Renu said:
8 years ago
Modulus & division are different.
Kennedy muriuki said:
8 years ago
I support answer C, fmod should be used in float where we need decimal points.
Amarjeet said:
8 years ago
I think the answer A is correct.
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?
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.
Banu said:
8 years ago
What is the correct answer for this question?
Tanushi said:
8 years ago
Please explain how this work?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers