0
why cant i use cin functions an input for age, ill post the program below
int age; cin>>age; if(age>=18){ cout<<"Adult"; else{ cout<<"Teenager"; } } if(age>0){ cout<<"Child"; else{ cout"something is wrong"; } } return 0; // would this work ?
2 Antworten
0
you have not closed the if statement.close it before starting else.
0
Hi Abhinav,
You should set the bracket of ages.
example
18+ = adult
10 to 17 = teen
9 below = child
here is my code, check this out:
#include <iostream>
using namespace std;
int main()
{
int age;
cin>>age;
if(age>=18)
{
cout<<"Adult";
}
else if(age>=10 && age<=17)
{
cout<<"Teenager";
}
else
{
cout<<"Child";
}
}