GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Tech FAQs  >  OOPS

 Print  |  
Question:  output and why?

main(){
float a=.5,b=.7;
if(b<.7)
if(a<.5)
printf("b<.7 and a<.5");
else
printf("b<.7 and a>=.5");
else
printf("b>=.7");
}




May 05, 2006 10:42:31 #3
 Gajanan   Member Since: Visitor    Total Comments: N/A 

RE: output and why?main(){ float a...
 
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"
     

 

Back To Question