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.
128
#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;
}
Run tries the examples. When they look right, Submit.