. . .

What are the logical operators in C give a suitable example with a program?

Use of Logical Operators

C allows usage of three logical operators, namely, &&, || and !.
These are to be read as ‘AND’ ‘OR’ and ‘NOT’ respectively.
There are several things to note about these logical operators. Mostly,
two of them are composed of double symbols, those are || and
&&. Don’t use the single symbol | and &.

The first two operators, && and ||, allow two or more conditions to be combined in an if statement. Let us see how they are used in a program.


void main()


int sub1, sub2, sub3, sub4, sum, avg;

printf("Enter the marks of four subjects");

scanf("%d %d %d %d", &sub1, &sub2, &sub3, &sub4);



printf("The Average Marks is %d\n",avg);


Please share the article

Leave a Reply

Your email address will not be published. Required fields are marked *

one × 3 =