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.

Loops – for | C Programming Fundamentals lesson | BraveProgrammer
  1. Courses
  2. /
  3. C Programming Fundamentals

Lesson 10 of 50

·c

Loops – for

7 mins

Course progress20%

What you'll learn

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

4 points
  • `for(init; condition; increment)` is syntactic sugar for a `while` loop.
  • All three parts are optional – `for(;;)` creates an infinite loop.
  • Scope of the loop variable (`int i`) is limited to the loop block (C99+).
  • Use `++i` (prefix) when the value isn’t needed inside the expression for a tiny performance gain.

for is the most common loop for counting.

for (int i = 0; i < 10; ++i) {
    printf("%d ", i);
}

The three parts are:

  1. initialization – executed once.
  2. condition – evaluated before each iteration.
  3. iteration expression – executed after each iteration.

You can omit any part if not needed (e.g., infinite loop).

Make it stickPractice what you've learned1 quiz · 3 practical tests · Optional activities from C Programming FundamentalsBrowse activities
Previous lessonLoops – while & do / whileContinue to lesson 11Functions – Declaration & DefinitionBack to C Programming Fundamentals curriculum