C – Logical Operators 2017-08-05T17:46:43+00:00

# Logical Operators :

• A Logical operator is used to compare or evaluate logical and relational expression.
• There are three logical operators in C language. They are
 Operator Meaning && Logical AND || Logical OR ! Logical NOT

Logical operators are used to calculate the value of logical expressions, ie expressions that the only values ​​that can take operands are True or False. Two versions of these operators. When you simply want to know if an expression is true or false (eg, x>7 ), operators are used lógicos . These operators do not consider the structure of bits, simply take the value 0 as false and any other as true. There is also another version (the bitwise) imposed by the logical operations to the bits used to internally represent the operands. These are the operators & , | and ~ , respectively.

Suppose that a and b are integer variables whose values are 100 and 4, respectively. Several arithmetic expressions involving these variables are shown below, together with their resulting values.

 Expression Interpretation Value (a>b)&&(a==100) True 1 (b>a)||(a>b) True 1 !(a>b) False 0