+ 1

Just I try insert "cin". Please check for my code it right or wrong? (I'm try to learn by my self.) / (Thank a lot for help.) ^^

#include <iostream> using namespace std; int main() { int age = 42; cin>>age; if (age == 16) { cout <<"Too young"; } if (age == 42) { cout << "Adult"; } if (age == 70) { cout << "Senior"; } return 0; }

18th Jan 2017, 5:35 PM
Red Eagle
Red Eagle - avatar
4 Respostas
+ 2
And what is the question?
18th Jan 2017, 6:46 PM
Dominik Wolfert
Dominik Wolfert - avatar
+ 2
The code is not wrong. The question is what you would like to do? What will happen, if your input is different from 16, 42 or 70?
18th Jan 2017, 7:10 PM
Dominik Wolfert
Dominik Wolfert - avatar
0
I'm sorry, I'm forget write the question.
18th Jan 2017, 6:51 PM
Red Eagle
Red Eagle - avatar
0
Ha Ha Ha! I don't know master Kenobi, I copy code from c++ tutorial and try insert "cin" for key the number on tutorial code, I want to know the code is compiler? I just padawan for c++ program, and I learning the c++ programing on first day, (I live in Thailand and I speak English just a little bit, if I use English wrong word, I'm so sorry for my stupid.)
18th Jan 2017, 7:39 PM
Red Eagle
Red Eagle - avatar