0

Can anyone help me out of this?? This is not working for value more than 5

https://code.sololearn.com/c5EFb5lQ3PEB/?ref=app

23rd Mar 2019, 10:29 AM
Gaurav Jain
2 ответов
+ 1
#include <iostream> using namespace std; int main() { int age,ageResult; cout<<"Enter your age:"<<endl; cin>>age; if (age<0) ageResult = -1; else if (age<5) ageResult = 0; else if (age<12) ageResult = 1; else if (age<19) ageResult = 2; else if (age<50) ageResult = 3; else if (age<60) ageResult = 4; else if (age<101) ageResult = 5; else ageResult = -1; cout<<"Your age belongs to:"<<ageResult<<"group"; return 0; } //That should work, you can't use conditions operator like : 0< age < 5 that is incorrect, either use (age > 0 && age < 5) or simple use : age < 5 in your case not all, first it checks if it is smaller than 0 then if it fails it checks if it is smaller than 5 and so on till the else statement
23rd Mar 2019, 10:52 AM
RZK 022
RZK 022 - avatar
+ 1
Hey thank you
23rd Mar 2019, 10:58 AM
Gaurav Jain