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

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


Please Help Members By Posting Answers For Below Questions

what is the diffrenet bettwen HTTP and internet protocol

1832


how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?

1933


In C programming, what command or code can be used to determine if a number of odd or even?

1051


What is the difference between malloc() and calloc() function in c language?

1074


What is a volatile keyword in c?

1163


What is the use of putchar function?

1055


What is the difference between near, far and huge pointers?

1091


p*=(++q)++*--p when p=q=1 while(q<=6)

1756


How pointer is different from array?

1072


What is a keyword?

1164


What is the 'named constructor idiom'?

1085


What is static memory allocation?

1169


Why are some ANSI/ISO Standard library routines showing up as undefined, even though I've got an ANSI compiler?

1125


What is the role of && operator in a program code?

1065


What is void main () in c?

1203