Kodewick
Start learning →
Basic←→0 / 86

First One Over 100

#083Basicif (x > 100) break;4 min

A sheet of paper doubles in thickness with every fold, starting at 1: 1, 2, 4, 8 … Show the **first number over 100**. The loop may run 20 times, but it should not have to — it stops as soon as the value passes 100. The answer is 128.

Should show
128
main.cpp
#include <iostream>
using namespace std;

int main() {
    int x = 1;
    for (int i = 0; i < 20; i++) {
        x = x * 2;
        // your code here: end the loop as soon as x is over 100
    }
    cout << x << endl;
    return 0;
}
Ctrl + Enter runs too
Result

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