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 8 of 15.
Siva Krishna said:
1 decade ago
@Vani :
In the inner printf statement, there are 4 characters.
The output of a printf stmt is a integer. that number is equal to the number of Characters that the printf statement printed.
For example:
printf("%d",printf("ABC"));
o/p= ABC4
-----------
printf("%d",printf("A"));
o/p= A1
-----------
printf("%d",printf("AB"));
o/p= AB2
-----------
printf("%d",printf("ABC10"));
o/p= ABC105
(here 10 is taken as two different characters.)
-----------
In the inner printf statement, there are 4 characters.
The output of a printf stmt is a integer. that number is equal to the number of Characters that the printf statement printed.
For example:
printf("%d",printf("ABC"));
o/p= ABC4
-----------
printf("%d",printf("A"));
o/p= A1
-----------
printf("%d",printf("AB"));
o/p= AB2
-----------
printf("%d",printf("ABC10"));
o/p= ABC105
(here 10 is taken as two different characters.)
-----------
Elakkiah said:
1 decade 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;
}
#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;
}
BDP said:
1 decade ago
% operator is not use for floating operations it is only used for integers.
Gautam said:
1 decade ago
Please explain fmod() and modf ().
POOJA said:
1 decade ago
Difference between fmode(), modef() and mode()?
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?
Shakir Baba said:
1 decade ago
Why array's base address is initialized to 0 and it terminates on -1?
Janani said:
1 decade ago
What is the difference between an identifier and variable?
Ayapan said:
1 decade ago
#include <stdio.h>
#include <math.h>
int main ()
{
printf ("fmod of 3.14/2.1 is %d\n", fmod(3,2) );
return 0;
}
I am getting output as 0. Anyone can explain it why?
#include <math.h>
int main ()
{
printf ("fmod of 3.14/2.1 is %d\n", fmod(3,2) );
return 0;
}
I am getting output as 0. Anyone can explain it why?
Shambhu kumar said:
1 decade ago
What is wrong in this code why it will give segmentation fault?
#include <stdio.h>
void main()
{
register int x = 0;
if (x < 2)
{
x++;
main();
}
}
#include <stdio.h>
void main()
{
register int x = 0;
if (x < 2)
{
x++;
main();
}
}
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers