Version without JavaScript, read-only: workshops, quizzes and running code are not available here. Full version · Catalogue · Sign in

Sequence

Even numbers from 0 to 20 (for)

Core exercise

Write afficherPairs() that prints, with a for loop, the even numbers from 0 to 20 inclusive, one per line.

A workshop goes here: you write and run code in it. It requires JavaScript.

Starting code

Exercices.java

public class Exercices {

    public static void main(String[] args) {
        afficherPairs();
    }

    public static void afficherPairs() {
        // TODO : une boucle for de 0 a 20
    }
}

The core exercise is validated in the workshop, which requires JavaScript.

Hint 1

Two ways: increment by 2 (i += 2), or increment by 1 and test i % 2 == 0.