← Back to archive

Stdle #20 · classes · 2026-06-26

What does this C++ snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

#include <iostream>
void addOne(int x) { x = x + 1; }
int main() {
int n = 41;
addOne(n);
addOne(n);
std::cout << n << "\n";
return 0;
}
Classes
4 attempts left

Answer & explanation