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

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


Please Help Members By Posting Answers For Below Questions

why wipro wase

2249


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......

1809


Explain how can I avoid the abort, retry, fail messages?

990


what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?

1801


Explain how do you print an address?

1087


What are the general description for loop statement and available loop types in c?

1074


int i=10; printf("%d %d %d", i, i=20, i);

1549


What are predefined functions in c?

1022


Where are some collections of useful code fragments and examples?

1107


about c language

1961


Apart from dennis ritchie who the other person who contributed in design of c language.

1321


Explain the difference between structs and unions in c?

959


Tell me the use of bit field in c language?

1016


i got 75% in all semester am i eligible for your company

2172


What is the Purpose of 'extern' keyword in a function declaration?

1033