Logical operators in c

Using logical operators we can check multiple conditions .this condition has two answers true or false ,for example “3 is odd or even number” the answer is true .there are so many multiple conditions in logical operators .these are shown in table 2

OperatorMeaningExample
&&Logical ANDIf c=1 and d=2 then, (c==1) && (d>1) equals to 0
||Logical ORIf c=1 and d=2 then, (c==1) || (d>1) equals to 1.
!Logical NOTIf c =1 then, expression ! (c == 1) equals to 0.

if there are two conditions .the logical operators works as shown in below table

logical operatorfirst conditionsecond conditionresult
&&truetruetrue
&&truefalsefalse
&&falsetruefalse
&&falsefalsefalse
||truetruetrue
||truefalsetrue
||falsetruetrue
||falsefalsefalse

example:

#include <stdio.h>
int main()
{
int a = 5, b = 5, c = 10, result;
result = (a = b) && (c > b);
printf("(a = b) && (c > b) equals to %d \n", result);
result = (a = b) && (c < b);
printf("(a = b) && (c < b) equals to %d \n", result);
result = (a = b) || (c < b);
printf("(a = b) || (c < b) equals to %d \n", result);
result = (a != b) || (c < b);
printf("(a != b) || (c < b) equals to %d \n", result);
result = !(a != b);
printf("!(a == b) equals to %d \n", result);
result = !(a == b);
printf("!(a == b) equals to %d \n", result);
return 0;
}
(a = b) && (c > b) equals to 1
(a = b) && (c < b) equals to 0
(a = b) || (c < b) equals to 1
(a != b) || (c < b) equals to 0
!(a == b) equals to 1
!(a == b) equals to 0
Press any key to continue . . .