Nearby lessons

26 of 72

C - if Statement

if Statement is one of the foundational topics in C programming. This lesson explains The if Statement with complete, runnable code examples, clear step-by-step explanations, and common mistakes to avoid with exam-style MCQs at the end.

The if Statement

Example01
Loading editor…

The if Statement

If the condition is true, the block runs; if false, it is skipped entirely.

Example02
Loading editor…
📝 Key Takeaways
  • if runs a block when the condition is true; else covers the false case.
  • if-else-if ladder chooses the first true condition.
  • Nested if = an if inside another if.
  • switch jumps to a matching case; remember break and default.
  • switch works with int/char, not float or string.
  • Ternary ?: is a one-line if-else.

🧠 Test Your Knowledge

1 Questions
Progress: 0 / 1

Finished this lesson?

Mark it as complete to track your progress and see technology completion stats.