C Programming Practice 3 on Logical Operator || Lesson 28 || C Programming || Learning Monkey ||

Publicado el: 09 junio 2021
en el canal de: Learning Monkey
583
8

C Programming Practice 3 on Logical Operator

In this class, we will try to solve some C Programming Practice 3 on Logical Operator.

We have already solved programming practice one and programming practice two.

Table of Contents

Programming Practice on Logical Operator
Program 1
Program 2

Programming Practice on Logical Operator

Let us consider the following two programs on logical operators.

Program 1
int a = 5, b = 6, c = 7, d = 4, e;
e = ab && cd || ad;

Program 2
int a = 10, b = 10, c = 3, d;
d = a == b & c;
Program 1

Let us consider the program below.

int a = 5, b = 6, c = 7, d = 4, e;
e = ab && cd || ad;

The above program has five variables a, b, c, d, and e.

The values of the variables a, b, c, d are 5, 6, 7, and 4.

The expression above has logical operators surrounded by relational terms.

To understand how the expression will be evaluated, we use the operator precedence and associativity table.

First, The relational expression will be executed from left to right.

The output of the expression after executing the relational terms is as shown below.

e = 0 && 1 || 1

Logical AND have the highest precedence than Logical OR operator.

From the above expression, the Logical AND will be executed first and produces an output of 0.

Now 0 || 0 will be executed and produces 1
Program 2

Let us consider the program below.

int a = 10, b = 10, c = 3, d;
d = a == b & c;

In the above expression, we have three operators Assignment operator =, Equality operator ==, and Bitwise AND operator.

From all the operators, the Equality operator has the highest precedence.

The expression after evaluating the equality operator is as shown below.

d = 1 & 3

Now the bitwise AND operator will be executed and produces one as the output.

The assignment operator has the least precedence, and d will be assigned to one.

#learningmonkey #cprogrammingforbeginners #placements #gatecse #cprogramming #cprogramminglanguage

Link for playlists:
   / @learningmonkey  


Link for our website: https://learningmonkey.in

Follow us on Facebook @   / learningmonkey  

Follow us on Instagram @   / learningmonkey1  

Follow us on Twitter @   / _learningmonkey  

Mail us @ [email protected]


En esta página del sitio puede ver el video en línea C Programming Practice 3 on Logical Operator || Lesson 28 || C Programming || Learning Monkey || de Duración hora minuto segunda en buena calidad , que subió el usuario Learning Monkey 09 junio 2021, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 583 veces y le gustó 8 a los espectadores. Disfruta viendo!