C Programming - Floating Point Issues - Discussion
Discussion Forum : Floating Point Issues - General Questions (Q.No. 5)
5.
Which statement will you add in the following program to work it correctly?
#include<stdio.h>
int main()
{
printf("%f\n", log(36.0));
return 0;
}
Answer: Option
Explanation:
math.h is a header file in the standard library of C programming language designed for basic mathematical operations.
Declaration syntax: double log(double);
Discussion:
14 comments Page 1 of 2.
Vinay Airan said:
2 decades ago
#include<stdio.h>
#include<math.h>
int main()
{
printf("%f\n", log(36.0));
return 0;
}
While i compile this code there is an error like..
In function `main':
undefined reference to `log'
why??
#include<math.h>
int main()
{
printf("%f\n", log(36.0));
return 0;
}
While i compile this code there is an error like..
In function `main':
undefined reference to `log'
why??
Kumar said:
2 decades ago
Since C is a compiler dependent language, it may give different outputs at different platforms. Here the Turbo-C Compiler (Windows) output has been given.
Please try the above programs in Windows (Turbo-C Compiler) and Linux (GCC Compiler), you will understand the difference better.
Please try the above programs in Windows (Turbo-C Compiler) and Linux (GCC Compiler), you will understand the difference better.
Well wisher said:
1 decade ago
Kumar is correct.
Varun said:
1 decade ago
What should be added here (in this case) to make output correct.
Devendra said:
1 decade ago
If we use stdio.h,ans. is -.000901 and using math.h ans is -.001263
Why is it different?
Why is it different?
Hajmaldeen said:
1 decade ago
How to run this program to unix?
Pratap Singh said:
1 decade ago
unsigned int i=65535;
int j;
j=i;
printf("%d",j);
output
-1 //// Why the output of j=-1 ....Please explain this
int j=-2;
unsigned int i=1+j;
printf("%u",i);
output
65535 //// Wht the output of i=65535
int j;
j=i;
printf("%d",j);
output
-1 //// Why the output of j=-1 ....Please explain this
int j=-2;
unsigned int i=1+j;
printf("%u",i);
output
65535 //// Wht the output of i=65535
Satti said:
1 decade ago
Range of signed integer is -32768 to 32767
but in unsigned integer case range is 65535
ie) 32768=-32768
32769=-32767
32770=-32766
.
.
.
65535=-1
thats why processor prints -1.
in ur second quetn j=-2
but i=1+j so i=-1; so the output prints 65535
but in unsigned integer case range is 65535
ie) 32768=-32768
32769=-32767
32770=-32766
.
.
.
65535=-1
thats why processor prints -1.
in ur second quetn j=-2
but i=1+j so i=-1; so the output prints 65535
Deepa said:
1 decade ago
What are the different b/w stdio, conio, stdlib? could any one?
Suyoj said:
1 decade ago
What is the difference between getch and getche ?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers