Skip to content
Quiz · Loops · lesson 2 of 8

Quiz — how many times the loop runs

What does the program print?

C++
#include <iostream>

int main() {
    int a = 0;
    for (int i = 0; i <= 5; ++i) { ++a; }
    int b = 0;
    for (int i = 1; i < 5; ++i) { ++b; }
    std::cout << a << ' ' << b;
}