Kodewick
Start learning →
Starter←→0 / 60

Pet badge

#016StarterStrings3 min

At the pet show every pet wears a badge: the name, a space, and its age in brackets, like Mimi (3). Write badge(name, age) to return the badge text.

Examples
badge("Mimi", 3)→'Mimi (3)'
badge("Rex", 10)→'Rex (10)'
The functionstring badge(const string &name, int age)
main.cpp
#include <string>
using namespace std;

string badge(const string &name, int age) {
    string text = name;
    // your code here: add " (", the age and ")" to text
    return text;
}
Ctrl + Enter runs too
Result

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