Kodewick
Start learning →
Starter←→0 / 86

Stop at Four

#082Starterbreak3 min

The plan was 1 to 9, but it should stop at 4. Show 1, 2, 3, 4 and nothing after. Leave the for line alone — do it inside the loop.

Should show
1
2
3
4
main.cpp
#include <iostream>
using namespace std;

int main() {
    for (int n = 1; n <= 9; n++) {
        cout << n << endl;
        // your code here: if n is already 4, end the whole loop
    }
    return 0;
}
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.