Write a C++ program to enter a number represents a person age then display the
following on a message boxes:
1. "Wrong age" if the age less than or equal to 0 years.
2. "Child" if the age less than 8 years.
3. "Boy" if the age greater than or equal to 8 years.
4. "Young" if the age greater than or equal to 18 years.
5. "Old" if the age greater than or equal to 35 years.
6. "Very Old" if the age greater than or equal to 65 years.
#include <iostream>
using namespace std;
int main() {
int age;
cout << "Enter age a person: ";
cin >> age;
if (age < 0){
cout << "Wrong age";
}else if (age < 8){
cout << "Child";
}else if (age < 18){
cout << "Boy";
}else if (age < 35){
cout << "Young";
}else if (age < 65){
cout << "Old";
}else {
cout << "Very Old";
}
return 0;
}
Comments
Leave a comment