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 do we use pointer to pointer in c?

1091


Is c compiled or interpreted?

1202


how to make a scientific calculater ?

2078


Why c is a mother language?

1047


What is the significance of scope resolution operator?

1419


What is the difference between array and pointer in c?

1174


please can any one suggest me best useful video tutorials on c i am science graduate.please help me.u can email me to sas29@in.com

1777


Is c language still used?

990


What is declaration and definition in c?

1107


What are logical errors and how does it differ from syntax errors?

1310


how to count no of words,characters,lines in a paragraph.

4434


When was c language developed?

1207


Is that possible to add pointers to each other?

1379


What are the 5 types of organizational structures?

1085


What are the advantages of c language?

1099