Abstract

The Boolean OR expression, AKA logical OR expression, is used to compute the Boolean or of two integer values, considered as Boolean.  In C, the Boolean OR operator short circuits, so Boolean OR expressions can also be used to control conditional execution.

Usage

The Boolean OR expression is used to compute the Boolean OR of two integer values, considered as Boolean values. 

Syntax

BNF

boolean-or-expression
::= <boolean-or-expression> <boolean-or-operator> <boolean-and-expression>
::= <boolean-and-expression>

EBNF

boolean-or-expression
::= <boolean-and-expression> ( <boolean-or-operator> <boolean-and-expression> ) *

Form

boolean-or-operator
||

Contextual Constraints

logical-or-operator
The operands of the OR operator should be of int type. 
The operands of the OR operator will be coerced to int type if possible. 

Semantics

boolean-or-expression

Example

#include <stdio.h>

void Display (int A, int B);

int main () {
  Display (0, 0);
  Display (0, 1);
  Display (1, 0);
  Display (1, 1);
  Display (2, 7);
  Display (15, 22);
}

void Display (int A, int B) {
  int C;
  C = A || B;
  printf ("%i || %i is %i\n", A, B, C);
}

Output


    

Reference Links

Boolean OR Operator boolean-or-operator
Bitwise OR Expression <bitwise-or-expression>
Boolean And Expression <logical-and-expression>
Boolean OR Expression
<boolean-or-expression>

Other Languages

C Now
C Boolean OR Expression
C++ Now C++ Boolean OR Expression
Java Now Java Boolean OR Expression
PHP Now PHP Boolean OR Expression