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]
Auf dieser Seite können Sie das Online-Video C Programming Practice 3 on Logical Operator || Lesson 28 || C Programming || Learning Monkey || mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Learning Monkey 09 Juni 2021 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 583 Mal angesehen und es wurde von 8 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!