Kodewick
Start learning →
Starter←→0 / 60

Stamp card

#034StarterReferences3 min

The café gives you a stamp on your card every visit. Write add_stamp(stamps) to add 1 to stamps. The parameter is a reference, int &, so the card outside changes too. stamps_after is already written and uses your add_stamp.

Examples
stamps_after(3, 2)→5
stamps_after(0, 0)→0
The functionint stamps_after(int start, int visits)
main.cpp
#include <iostream>
using namespace std;

void add_stamp(int &stamps) {
    // your code here: add 1 to stamps
}

int stamps_after(int start, int visits) {
    int card = start;
    for (int i = 0; i < visits; i++) {
        add_stamp(card);
    }
    return card;
}
Ctrl + Enter runs too
Result

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