Welcome Guest | Sign in | Register
If statements - Discussion Page For Q.10523 | C Programming Questions and Answers | C Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > If statements > Questions and Answers

Q: What will be output of the following program?
#include
int main()
{
float a=0.7;
if(a<0.7){
printf("C");
} else{
printf("C++");
}
return 0;
}  
A. C B. C++
C. NULL D. Compilation error
E. None of these

Answer and Explanation

Answer:C

Explanation:
0.7 is double constant (Default). Its binary value is written in 64 bit. Binary value of 0.7 = (0.1011 0011 0011 0011 0011 0011 0011 0011 0011 0011 0011) Now here variable a is a floating point variable while 0.7 is double constant. So variable a will contain only 32 bit value i.e. a = 0.1011 0011 0011 0011 0011 0011 0011 0011 while 0.7 = 0.1011 0011 0011 0011 0011 0011 0011 0011 0011 0011 0011.... It is obvious a < 0.7  

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.