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; }
4 Respostas
+ 1
maybe you forgot some "else" keywords after each "if condition" ;)
0
you have forgotten the stream insertion operator (<<) in the 2nd last cout. Also there is no true condition if the years = 4.
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?
0
Thanks!