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
No output; since (x == 1.1) will return false.
Explanantion:
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 ? | 6 Yes | 0 No |
Post New Answer View All Answers
why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???
What is the purpose of 'register' keyword in c language?
Can you mix old-style and new-style function syntax?
How many levels of pointers have?
Can you add pointers together? Why would you?
What is the use of bitwise operator?
i got 75% in all semester am i eligible for your company
can any one provide me the notes of data structure for ignou cs-62 paper
Explain output of printf("Hello World"-'A'+'B'); ?
Explain what is the best way to comment out a section of code that contains comments?
how could explain about job profile
Why c language?
What are the Advantages of using macro
Where local variables are stored in c?
What is register variable in c language?