what is the output of the following program?
#include<stdio.h>
void main()
{
float x=1.1;
while(x==1.1)
{
printf("\n%f",x);
x=x-0.1;
}
}
Answer Posted / shibumon alampatta
First of all we shall look into the binary representation of
decimal number 1.1. It is 1.00011001100110011..... reccuring
infinite fractional part. And in the expression (x == 1.1),
x is a float and 1.1 is double constant. So their precisions
are different and float x = 1.1 and the double constant 1.1
will not be equal. So if we make double x = 1.1, instaed of
float it will work. Also if it is float x = 1.5 then the
expression (x == 1.5) will return true; because binary form
of 1.5 is 1.1; which is finite and both flaot and double
will have same value.
| Is This Answer Correct ? | 11 Yes | 0 No |
Post New Answer View All Answers
why wipro wase
can any one please explain, how can i access hard disk(physical address)? it is possible by the use of far,near or huge pointer? if yes then please explain......
Explain how can I avoid the abort, retry, fail messages?
what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?
Explain how do you print an address?
What are the general description for loop statement and available loop types in c?
int i=10; printf("%d %d %d", i, i=20, i);
What are predefined functions in c?
Where are some collections of useful code fragments and examples?
about c language
Apart from dennis ritchie who the other person who contributed in design of c language.
Explain the difference between structs and unions in c?
Tell me the use of bit field in c language?
i got 75% in all semester am i eligible for your company
What is the Purpose of 'extern' keyword in a function declaration?