+ 2
Exam question
İnt main () { int a=5 , b=0 , c=10 , result; result = ( a = b) && ( c > b ) ; printf("%d \n", result) ; } How does this program can be equal to 0? Can you explain it?
2 Antworten
+ 2
It looks like one = is missing. Should it be (a==b)?
As it is, a is given the value of b: zero. And zero is evaluated as false.
The second part c>b is true, but you wrote a=b AND c>b, so this ends up as false.
false gets converted to int (zero) and stored in result.
+ 1
ın the question ( a = b )