C++ Quiz6 of 173
Difficulty:
⬅️ Prev: 5Quiz ID: 6Next: 7 ➡️

According to the C++23 standard, what is the output of this program?

#include <iostream>

int main() {
  for (int i = 0; i < 3; i++)
    std::cout << i;
  for (int i = 0; i < 3; ++i)
    std::cout << i;
}
Hint

When is i incremented?

Reveal answer

012012

Explanation

Whether you post-increment or pre-increment i, its value does not change until after the loop body has executed.

⬅️ Prev: 5Quiz ID: 6Next: 7 ➡️