+ 2
Why this piece of code print c++ when condition is not true
Why this piece of code print c++ #include<stdio.h> Int main () Float a=0.7; If(a>0.7) { Printf("C"); Printf("++"); } Return 0; }
3 odpowiedzi
+ 2
Double type is the default type for decimal values.
In your code 0.7 is double type value.
So both, a, 0.7 are converted equal type, obviously to higher double type, and when converted, because convertion, that a contains slightly higher value than double 0.7.
0.7 odd value, this is not same happens if is even, ex :0.8.
So double type values is obviously greater than float value in the internals.. And also they are not same..
Check by this..
if(a==0.7)
printf("same double");
if(a==0.7f)
printf("same float");
0
Your float a is not bigger than 0.7. They're equal.
Your compare holds that printing will happen, if a is bigger than 0.7
And I think you should type in lowercase like
int, float, if etc
0
https://code.sololearn.com/cKWndM3klL01/?ref=app
See this code it gives no output.