Presumably, you mean if (i==4 && j==9) .
Under the circumstances, the change in this parameter from && to & should not change much. The big thing that will change is that with && value j==9 will only be evaluated if part i==4 was true, but with & they will both be evaluated independently.
If you have something like if (x != NULL && x->whatever ...) , you want to make sure that the second part (these markups x ) is evaluated only if x not a null pointer. In your case, however, comparing what seems to int is unlikely to cause any problems.
You may also run into a problem when you are dealing with something that could lead to a value other than 1 to a true signal. Again, this is not a problem, because == will always produce either 0 or 1 . If (for example) you used isalpha , islower , etc., from <ctype.h> , they should only create 0 or non-zero values. If you combine those that have & , you get a bit-wise or , which could produce 0 for two non-zero inputs (for example, 1 & 2 == 0 , but 1 && 2 == 1 ).
When you use the bitwise and result from == , you will get 0 & 0 or 0 & 1 or 1 & 0 or 1 & 1 . 1 & 1 will give 1 (true). Everyone else will give 0 (false) --- exactly the same as && .
source share