0

Can someone help me,i don't understand what's wrong?

#include <iostream> using namespace std; int main() { float years; cin>>years; if(years<4) { cout<<"You are a baby.";} if(years<13 && years>3) { cout<<"You are a child.";} if (years<20 && years>12) { cout<<"You are a teenager.";} if(years>19 && years<60) { cout<<"You are an adult.";} if(years>59 && years<100) { cout"You are a senior."; } if (years>100) { cout<<"You are very,very old."; } return 0; }

27th Nov 2016, 8:43 PM
Johnny
Johnny - avatar
4 odpowiedzi
+ 1
maybe you forgot some "else" keywords after each "if condition" ;)
27th Nov 2016, 9:08 PM
Nima Moradi
Nima Moradi - avatar
0
you have forgotten the stream insertion operator (<<) in the 2nd last cout. Also there is no true condition if the years = 4.
27th Nov 2016, 9:09 PM
Mohammed Maaz
Mohammed Maaz - avatar
0
Well you should add " << endl" to eatch cout statement so the stream gets flushed. and you will get no out put for 100 as you dont check for that. Also, why not use än int for years?
27th Nov 2016, 9:09 PM
Mattias Eriksson
Mattias Eriksson - avatar
0
Thanks!
28th Nov 2016, 10:27 AM
Johnny
Johnny - avatar