Key Concepts

Review core concepts you need to learn to master this subject

Types of Loops

Loops can be written as while loops, do-while loops, and for loops.

Loops: Lesson
Lesson 1 of 1
  1. 1
    A loop is a way to repeat code or a set of instructions until a specified condition is reached. For example, have you ever been looking for somebody in a grocery store? You check each aisle un…
  2. 2
    Before we dive deep into the syntax of a loop, let’s do a demo! We have a program that asks and checks for a pin. It uses a while loop, which will be the first type of loop we’ll learn about, to a…
  3. 3
    Now that you’ve interacted with a loop, let’s write one! The while loop looks very similar to an if statement. And just like an if statement, it executes the code inside of it if the condition i…
  4. 4
    For the last loop we held your hand, so let’s try one on your own! As an example of iteration, we have the first program ever to run on a stored-program computer (the [EDSAC](https://en.wikipedia….
  5. 5
    Now that we’ve written a while loop, let’s write an alternate form of it. We’ll look at its syntax first then explain what’s happening and why: do { // Statement(s) } while (condition); This …
  6. 6
    The while loop examples we’ve looked at so far iterate over a sequence of numbers. This is so common that C, like most other programming languages, has a special syntax for it. When we know exactl…
  7. 7
    When working with loops, it’s important to know a few special keywords that can affect how a loop runs. Let’s look at a quick example to introduce the first special keyword! Do you remember the wh…
  8. 8
    In a video game, a “Game Over” screen often allows you to “continue” from a previous save or checkpoint. Loops can do this in much the same way using continue, the second keyword we’ll learn this l…
  9. 9
    Great job! You completed the lesson on loops! 🙌 Key concepts covered in this lesson: - Loops perform repetitive actions so we don’t have to code those actions manually every time. - How to write w…

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo