0

Float a=0.7; if(a<0.7) print (yes) else (no)

what will be output? A)yes B)No C)YesNo And why?

7th Sep 2017, 2:43 PM
Jadeja Manaharsinh
Jadeja Manaharsinh - avatar
2 Respostas
+ 6
because a is 0.69999999998 in it's floating representation. When you assign a=0.7 in memory 0.7 cannot be represented in double precision as you would have thought. So the comparison between float and double leads to type promotion and in that case a is less than 0.7 which is double.
7th Sep 2017, 3:06 PM
Atul Agrawal
- 2
is this a question? print isnt a thing in cpp and the syntax is wrong for half of it but assuming its correct i still dont understand the question.
7th Sep 2017, 3:05 PM
Enzo
Enzo - avatar