(Assuming C, C++, Java, JavaScript)
|
and &
are bitwise operators while ||
and &&
are logical operators. Usually you'd want to use ||
and &&
for if statements and loops and such (i.e. for your examples above). The bitwise operators are for setting and checking bits within bitmasks.