Logical Operators in C

The logical operators are used when we want to test more than one condition and decisions.the following list , example and description of logical operators.

Sr.No

Options

Descriptions

01

&&

AND

02

||

OR

03

!

NOT

The above list of logical operator in c programming,the below table truth table of logical operator.

OP1

OP2

OP1 && OP2

OP1 || OP2

1

1

1

1

1

0

0

1

0

1

0

1

0

0

0

0

Example


#include
#include
void main()
{
int a , b , c;
clrscr();
a = 4 , b = 3;
c = a && b;
b = a||b||c;
a = a && b||c;
printf("%d" , a\n);
printf("%d" , b\n);
printf("%d" , c\n);
}
							

Output


1
1
1
							
Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit

You may also like this!