+ 15
Here is a revision of your original work. #include <iostream> using namespace std; int main() { int age = 43; cout << "Enter your age: "; cin >> age; if (age < 3 && age >= 1) cout << "Toddler"; else if (age < 5 && age >= 3) cout << "Preschooler"; else if (age < 12 && age >= 5) cout << "Gradeschooler"; else if (age < 18 && age >= 12) cout << "Teen"; else if (age < 43 && age >= 18) cout << "Adult"; else if (age < 70 && age >= 43) cout << "Senior"; else cout << "The age is uncategorized."; } As you see, if...else statement is more fit for your problem.
19th Oct 2017, 2:02 PM
Babak
Babak - avatar