- 01Getting Started
- 02Your First Output (printf)
- 03Working with Variables
- 04Conditionals (if statements)
- 05Loops (for statements)
- 06Writing a Function
- 07Working with Arrays
- 08Loops (while statements)
- 09Working with Structs
- 10Error Handling (Checking a Return Value)
- 11Sorting an Array (Bubble Sort)
- 12Recursive Functions
- 13The String-Handling Standard Library
- 14The switch Statement
- 15The Ternary Operator
- 16Pointer Basics
- 17Writing Comments
- 18Logical Operators (&&, ||, !)
- 19Constants (#define and const)
- 20Splitting Strings (strtok)
- 21Handling NULL Pointers Safely
- 22Searching an Array (Looping with strcmp)
- 23Transforming an Array (map-like Logic)
- 24Two-Dimensional Arrays (Tabular Data)
- 25Custom Errors (Categorizing with Error Codes)
- 26Using Variable-Length Argument Lists (stdarg.h)
- 27Removing Duplicates from an Array (Set-Like Logic)
- 28Checking Correctness with the assert Macro (Your First Step into Testing)
- 29Higher-Order Functions (Passing a Function Pointer as an Argument)
- 30Stacks and Queues (Basic Data Structures)
- 31Type Conversion (Casting) Basics
- 32Intro to Regular Expressions (regex.h)
- 33The Binary Search Algorithm
- 34Building a Caesar Cipher (a Character-Shifting Cipher)
- 35Understanding How Selection Sort Works
- 36Building and Displaying Dates (struct tm)
- 37Writing Multiple Test Cases Together
- 38Speeding Up Calculations with Memoization (Caching)
- 39Normalizing Strings (Stripping Whitespace, Unifying Case)
- 40Shallow Copy vs. Deep Copy
- 41Enum (Enumerated Types) Basics
- 42Flattening an Array
- 43Reversing a String and Checking for Palindromes
- 44Pairing Up Two Arrays (the zip operation)
- 45Rounding Numbers (floor, ceil, round)
- 46Multi-Line Strings (Adjacent String Literal Concatenation)
- 47Functions That Return Multiple Values (Structs)
- 48Finding the GCD and LCM (the Euclidean Algorithm)
- 49Formatting Numbers (Padding Digits, Decimal Places)
- 50Bundling Cleanup Logic with goto
- 51Writing Type-Agnostic Logic with Macros
- 52File Reading and Writing Basics
- 53Generating Random Numbers
- 54Bitwise Operators (AND, OR, XOR, shifts)
- 55Reading Command-Line Arguments
- 56Waiting for a Fixed Amount of Time (sleep)
- 57Watch Out for Floating-Point Rounding Errors
- 58Reading from Standard Input
- 59FizzBuzz (the Classic Practice Problem)
- 60Checking Whether a Number Is Prime
- 61Set Operations with an Array (Intersection, Difference)
- 62Converting Number Bases (Binary, Hex)
- 63Checking Balanced Parentheses (an Application of Stacks)
- 64Checking Whether Two Words Are Anagrams
- 65Checking Whether a Year Is a Leap Year
- 66Converting Temperature (Celsius to Fahrenheit)
- 67Prime Factorization
- 68[Applied] Build a Simple Grade Aggregation Program
Logical Operators (&&, ||, !)
This lesson covers C's logical operators — &&, ||, and ! — so you can combine multiple conditions in a judgment. It's for anyone searching "C logical operator usage."
Use logical operators to combine conditions. && means "both are true," || means "at least one is true," and ! negates a condition.
The example uses age >= 18 && hasTicket to check "18 or older and has a ticket," and age < 18 || !hasTicket to check "under 18, or doesn't have a ticket." Notice that, historically, C has no dedicated boolean type — 1 is treated as true.
A common early mistake is not knowing about short-circuit evaluation. Not realizing that the right side of && is skipped entirely when the left side is false can lead to unexpected behavior if the right side has a side effect.
In real projects, this is a frequently-used operator inside if statements, essential for combining conditions like "18 or older, and has a ticket" into a single check.
🧪 This site can't compile or run C directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser — nothing is sent anywhere).
