C Programming - Floating Point Issues - Discussion
Discussion Forum : Floating Point Issues - Find Output of Program (Q.No. 4)
4.
What will be the output of the program?
#include<stdio.h>
#include<math.h>
int main()
{
printf("%f\n", sqrt(36.0));
return 0;
}
Answer: Option
Explanation:
printf("%f\n", sqrt(36.0)); It prints the square root of 36 in the float format(i.e 6.000000).
Declaration Syntax: double sqrt(double x) calculates and return the positive square root of the given number.
Discussion:
15 comments Page 2 of 2.
Ishi said:
1 decade ago
@D Suresh.
As you said float value display six value after decimal than, what about double and long double?
As you said float value display six value after decimal than, what about double and long double?
Raj said:
1 decade ago
How 36 is double, please explain?
Deepak said:
9 years ago
If 36.0 is double then it should give 14 digits of precision then answer would be 6.00000000000000.
Janavi said:
6 years ago
Generally, the float value will display like six digits after the decimal point so, the output of the above program will be 6.000000 because of √(36.0) =6.000000.
So whenever we have to calculate the sq.root of decimal digits there are always ans is value .000000.
So whenever we have to calculate the sq.root of decimal digits there are always ans is value .000000.
Surbhi Rajput said:
6 years ago
How it can be double?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers