Kodewick
Start learning →
Basic←→0 / 86

The Bouncing Ball

#080Basicheight = height / 24 min

A ball drops from 100 cm and bounces back half as high each time (whole-number division, so the rest is dropped). Show the height of every bounce, one per line, stopping once it is under 10 cm.

Should show
50
25
12
6
main.cpp
#include <iostream>
using namespace std;

int main() {
    int height = 100;
    while (height >= 10) {
        height = height / 2;
        // your code here: show how high this bounce went
    }
    return 0;
}
Ctrl + Enter runs too
Result

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