From the course: Complete Guide to C Programming Foundations
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Using logical operators - C Tutorial
From the course: Complete Guide to C Programming Foundations
Using logical operators
- [Instructor] The C languages' two primary logical operators are AND and OR. The logical and operator is two ampersands. For a logical AND expression to be true, both of its conditions must be true. The logical OR operator is two pipes or vertical bars. For a logical OR operation to be true, either of its conditions must be true. Typically, the logical expressions are used with relational operators as shown in this exercise file. At line nine, if the value of variable A is greater than 6 and its value is less than 15, this expression evaluates true, because both conditions are true. As the value of variable A loops from 1 to 20, each value is processed in this manner. In the output, you see asterisks prefixing the output from lines 7 through 14. Now edit the logical expression so that it reads: When ( a < 6 || a > 15 ) Can you guess what the output might be? Only values less than 6 and greater than 15 have asterisks. Edit the expression again. Let's replace it with ( a >= 16 || a ==…
Contents
-
-
-
-
-
Working with math operators3m 13s
-
(Locked)
Challenge: Do some math50s
-
(Locked)
Solution: Do some math1m 47s
-
(Locked)
Using assignment operators1m 49s
-
(Locked)
Obeying the order of precedence3m 14s
-
(Locked)
Challenge: Get the order correct55s
-
(Locked)
Solution: Get the order correct1m 37s
-
(Locked)
Working with relational operators3m 48s
-
(Locked)
Using logical operators3m 58s
-
(Locked)
Understanding bitwise operators3m 44s
-
(Locked)
Shifting bits3m 13s
-
(Locked)
Exploring unary operators3m 3s
-
Chapter challenge: More math1m 8s
-
(Locked)
Chapter solution: More math2m 45s
-
-
-
-
-
-
-
-
-