+ 3
I need help for my cpp age identifier
I got inspired by sl who had in one of his cpp lessons an example of that so i tried to make something like this but it doesnt show any input how to do it? https://code.sololearn.com/c45jSIx84SoM/?ref=app
3 Réponses
+ 11
Your 'cin' statement on line 7 inputs to nothing. Replace with:
cin >> age;
Tbh, the logics seemed kinda off, so I adjusted a few lines. Please take a look:
#include <iostream>
using namespace std;
int main()
{
int age;
cin>> age;
if (age > 0) {
if (age > 14) {
if(age >= 18) {
cout << "Adult";
if (age>=100) {
cout << " - You are gonna live way too much";
}
else if (age>=60){
cout << " - overaged";
}
}
else {
cout << "Teenager";
}
}
else {
cout << "Child";
}
}
else {
cout << "Something's wrong";
}
return 0;
}
+ 2
write
cin>>age
as it defines the variable that will take the input
+ 1
also use for >=60 and >=100 in the >14 condition