Kodewick
Start learning →
Starter←→0 / 86

Two Kinds of Division

#064Startercookies / kids, cookies / 2.03 min

7 cookies shared between 2 kids. First show how many whole cookies each one gets, then show the answer as a decimal. Two lines, one number each.

This is the classic trap: in C++, 7 / 2 is **not** 3.5.

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

int main() {
    int cookies = 7;
    int kids = 2;
    // your code here: show 7 divided by 2, whole part only
    // your code here: show 7 divided by 2 as a decimal
    return 0;
}
Ctrl + Enter runs too
Result

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