Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Control Flow – if / else | C Programming Fundamentals lesson | BraveProgrammer
  1. Courses
  2. /
  3. C Programming Fundamentals

Lesson 7 of 50

·c

Control Flow – if / else

6 mins

Course progress14%

What you'll learn

Keep these ideas in mind as you work through the lesson.

4 points
  • `if (condition) statement;` – condition must evaluate to non‑zero for true.
  • `else` runs when the `if` condition is false.
  • Multiple `else if` branches can be chained.
  • Always use braces `{}` to avoid dangling‑else bugs.

if statements execute a block when a condition is true. An optional else clause runs when the condition is false.

if (x > 0) {
    printf("positive
");
} else {
    printf("non‑positive
");
}
Make it stickPractice what you've learned1 quiz · 3 practical tests · Optional activities from C Programming FundamentalsBrowse activities
Previous lessonOperators OverviewContinue to lesson 8Control Flow – switchBack to C Programming Fundamentals curriculum