Output and why?main(){ float a=.5,b=.7; if(b

Questions by vaasu

Showing Answers 1 - 11 of 11 Answers

Umme Zakira

  • May 25th, 2006
 

the output is printf("b<.7 and a>=.5");

  Was this answer useful?  Yes

Rajan

  • May 25th, 2006
 

the out put is b>=.7because the if condition not satisfied na

  Was this answer useful?  Yes

Gajanan

  • May 30th, 2006
 

The output will be this=> "b<.7 and a<.5"because the fractional values are not stored as it is into the variables...they will be stored as an approximate values.see here a=.5 assigned which will be stored as .99999996where as the variable 'a' is compaired with constant .5 which is a constant and stored as it is!!!obiviousaly then a<.5.the same applicable for .7 and 'b'so the answer is "b<.7 and a<.5"

  Was this answer useful?  Yes

lipi chandran

  • Jun 1st, 2006
 

output : b>=.7

because as first if cond doesnt satisfy it doesnt go to second if cond & else part, so the control goes to outer else part.

  Was this answer useful?  Yes

Suvarna

  • Jun 3rd, 2006
 

output = a<.7 and b<.5 as float values are stored less then the actually are.

  Was this answer useful?  Yes

Akash

  • Feb 6th, 2007
 

The output of the above programme will be b<0.7 and a>=0.5 .7 is not stored as 0.7 ie it is stired to some value which is slightly less that 0.7 so the control will not work as expected [this is the only excception i guess for floating point nos]

  Was this answer useful?  Yes

KishoreKNP

  • Dec 2nd, 2009
 

Each and every float constant in C/C++ treated as double, because of this this program won't work as you expected. Add "f" like ".7f" after every float constant then it works as you expected.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions