Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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;
}
}

Answers were Sorted based on User's Feedback



what is the output of the following program? #include<stdio.h> void main() { float x=1.1;..

Answer / vikram

No output.Since a float variable is compared with double
constant,condition will not satisfy.
if you don't believe,try your hand on it.

Is This Answer Correct ?    31 Yes 3 No

what is the output of the following program? #include<stdio.h> void main() { float x=1.1;..

Answer / battini.laxman

No output.Loop will not execute atleast once. because
compiler will treat real constant as double. So real
constants will not store exactly equal to that constant
value but appproximately equal to that constan in binary
format. So float value and doule value storing
approximately equal but not exactly.small difference will
be there.so condition will fail at first time.So loop will
not execute atleast once.

Is This Answer Correct ?    17 Yes 0 No

what is the output of the following program? #include<stdio.h> void main() { float x=1.1;..

Answer / 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

what is the output of the following program? #include<stdio.h> void main() { float x=1.1;..

Answer / 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

what is the output of the following program? #include<stdio.h> void main() { float x=1.1;..

Answer / vignesh1988i

for the first time the loop will be true and it will print as 1.100000 , after reading the next line x will be 1.0, so again when it comes into while loop 1.000000 not equal to 1.100000 so it will come outside the loop

Is This Answer Correct ?    4 Yes 20 No

what is the output of the following program? #include<stdio.h> void main() { float x=1.1;..

Answer / gangadhar

first time loop will satisfy and second time loop will
not satisfy bcoz x become zero....

Is This Answer Correct ?    0 Yes 17 No

Post New Answer

More C Interview Questions

How many data structures are there in c?

0 Answers  


What are loops in c?

0 Answers  


what is the diff b/w static and non static variables in C. Give some examples plz.

3 Answers   Wipro,


while initialization of array why we use a[][2] why not a[2][]...?

0 Answers   Aptech,


Please write the area of a RIGHT ANGLED TRIANGLE.

1 Answers  


How can you invoke another program from within a C program?

0 Answers  


program to find the magic square

1 Answers   Infosys,


What are formal parameters?

0 Answers  


How can I swap two values without using a temporary?

0 Answers  


Write down the program to sort the array.

4 Answers   Impiger,


What are the basic data types associated with c?

0 Answers  


main() { char x; while(x=0;x<=255;x++) printf("\nAscii value %d Charater %c",x,x); }

2 Answers  


Categories