#include <iostream>
using namespace std;
int main() {
int num1;
cout << "What is your age? ";
cin >> num1;
if (num1 >= 0 && num1 <= 14) {
cout << "\nChild" << endl;
}
else if (num1 >= 15 && num1 <= 24) {
cout << "\nYouth" << endl;
}
else if (num1 >= 25 && num1 <= 64) {
cout << "\nAdult" << endl;
}
else if (num1 >= 65) {
cout << "\nSenior" << endl;
}
else {
cout << "\nPlease input valid number." << endl;
}
return 0;
}
Yung output po kasi kapag input yung any type of alphabet is Child yung lalabas ano po solution dito na kapag hindi number yung lalabas "Please input valid number"
using namespace std;
int main() {
int num1;
cout << "What is your age? ";
cin >> num1;
if (num1 >= 0 && num1 <= 14) {
cout << "\nChild" << endl;
}
else if (num1 >= 15 && num1 <= 24) {
cout << "\nYouth" << endl;
}
else if (num1 >= 25 && num1 <= 64) {
cout << "\nAdult" << endl;
}
else if (num1 >= 65) {
cout << "\nSenior" << endl;
}
else {
cout << "\nPlease input valid number." << endl;
}
return 0;
}
Yung output po kasi kapag input yung any type of alphabet is Child yung lalabas ano po solution dito na kapag hindi number yung lalabas "Please input valid number"