Please enable JavaScript to use CodeHS

AP Computer Science A (Nitro)

Lesson 4.2 For Loops

Description

In this lesson. students learn how to use for loops in their programs. The for loop allows students to repeat a specific part of code a fixed number of times.

For loops are written like this:

for(int i = 0; i < 4; i++)
{
    // Code to be repeated 4 times
}

This lesson corresponds with AP Computer Science A topic 4.2.


Objective

Students will be able to:

  • Represent iterative processes using a for loop