Shouldn't there be a way to input information in the code so the *if* statement can go into effect? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Shouldn't there be a way to input information in the code so the *if* statement can go into effect?

I'm currently on the "else statement" lesson of c++ and I find it strange that the code does not ask me for input to run. Like, {int age= 18 if (age>4) {cout<<"Adult";} else{cout<<"Teenager";} If I don't input anything there's no use is there? Shouldn't there be var and cin things around there? Also, if somebody could explain why the bracket patterns seem so weird (I don't understand why they're ordered how they are. I see a huge mess) that'd be great.

8th Oct 2017, 2:01 AM
Anonymousgirl
3 Answers
+ 7
Yes you need to use cin Anything you doubt?
8th Oct 2017, 2:21 AM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
0
It is just an example to demonstrated the concept, it isn't meant to be a real useful program.
8th Oct 2017, 2:29 AM
John Wells
John Wells - avatar
0
Oh, so it's just an example then.. Thank you 😊
8th Oct 2017, 2:32 AM
Anonymousgirl