0
How || is functioned when it is used for two numbers??
2 Respuestas
+ 2
the numbers are implicitly converted to booleans. 0 becomes false, all other nuns are true. then they undergo logical or operation.
0
In C (and C++) a zero value is false, anything else is true.
https://en.wikipedia.org/wiki/C_data_types#Boolean_type
Logical OR operator (||) returns false only if both operands are false, and true if any of the operands or both of them are true.
So, in your example, i||j is 4||-1, which is true||true, which returns true. When a value is interpretted as a logical value (boolean), it becomes 1 if it is true, and 0 is it is false ("any assignments to a _Bool that are not 0 (false) are stored as 1 (true)" — wiki). So 1 gets printed out.