Answer to Question #335607 in C++ for Teddy

Question #335607

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.

1
Expert's answer
2022-04-29T18:22:16-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS