Logical operators evaluate expressions—usually using a set of relational operators—to determine whether one, both, or neither conditions are true. Use the logical AND operator (&&) to determine when both expressions are true and the logical OR operator (||) when either expression must be true.
- The C language has two primary logical operators, … 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 expression 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. … In line A, this expression reads, … if the value of variable a is greater than six … and the value of variable a is less than 15. … If both expressions are true, … the if statement evaluates true … and the putchar statement outputs an asterisk. … In the while loop, the value of variable a loops … from one through 20, … and this test is performed on each of those values. … Build and run, … and you see the asterisks are prefixed … only on values between six and 15. … Now edit the logical expression … so that it reads a is less than six … or a is greater than 15. …
- Writing your first C program
- Working the C development cycle
- Adding comments to code for clarity
- C language data types
- Declaring variables
- Making new data types
- Typecasting variables
- Using math, assignment, and logical operators
- Creating for and while loops
- Nesting loops
- Creating functions
- Returning values from functions
- Passing arguments to functions
- Creating recursive functions
Skill Level Intermediate
C: Data Structures, Pointers, and File Systemswith Dan Gookin2h 57m Intermediate
1. The Fundamentals of C
2. Variables and Values
3. Operators and Math
4. Decisions and Loops
Next steps1m 38s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.