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 is #define used?
What is wild pointer in c?
Why static is used in c?
Explain what is the most efficient way to store flag values?
Explain the use of 'auto' keyword in c programming?
Can the sizeof operator be used to tell the size of an array passed to a function?
write a c program for swapping two strings using pointer
what is a function method?give example?
the question is that what you have been doing all these periods (one year gap)
What are the types of pointers?
What are c header files?
Write a program to generate a pulse width frequency of your choise,which can be variable by using the digital port of your processor
Can a function argument have default value?
A c program to display count values from 0 to 100 and flash each digit for a secong.reset the counter after it reaches 100.use for loop,. pls guys hepl me.. :(
What are the valid places to have keyword “break”?