+ 3

How the '&' operator works in if-else statement and What is the difference between '&' and '&&' in logical operation.

Suppose :- int a=8,b=8; if(a==8 & b==a) return 1; Earlier I thought that this will be a error but when I checked it actually returns 1, So what is the difference with '&&'. I think it takes true to be 1 and false to be 0 , then performs bitwise operation and again converts the results to boolean.Did I am correct??

2nd Mar 2017, 11:59 AM
Mr.Curious
Mr.Curious - avatar
1 Odpowiedź
+ 9
You should check this question, it is exactly what you are asking 😉 : http://stackoverflow.com/questions/5564410/difference-between-and
2nd Mar 2017, 12:12 PM
C.E.
C.E. - avatar