PROBLEM 52
Medium

Age Category

Programming Basics · C++

</>
STATUS Not solved

TASK

Problem

#52

Given a non-negative age in years, print `child` for ages below 13, `teen` for 13–17, `adult` for 18–64, and `senior` for 65 or more.

EXAMPLE

Example

Input
5
Output
child

LIMITS

Constraints

0 ≤ age ≤ 150.
📖
LEARN Theory for this problem
+

An `if` / `else if` / `else` chain checks alternatives from top to bottom. Put more specific or higher-priority conditions first.

Connection to “Age Category”: here, branching selects a case using a Boolean condition; test order matters when cases overlap.

💡
NEED HELP? Hints
+

['List the possible cases and make them mutually exclusive.', 'After solving “Age Category”, verify the algorithm on your own small example and on an allowed boundary case. Print only the required result with no extra text.']

ANSWER Solution
+
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    long long n;
    cin >> n;
    if (n < 13) cout << "child";
    else if (n < 18) cout << "teen";
    else if (n < 65) cout << "adult";
    else cout << "senior";
    cout << '\n';
    return 0;
}