+ 1

Getting an error while scan and print for if condition

int main() { int age; cin >>"age"; if (age == 16) { cout <<"Too young"; } if (age == 42) { cout << "Adult"; } if (age >= 60) { cout << "Senior"; }

18th Sep 2018, 2:02 PM
shahul hameed aljas TA
shahul hameed aljas TA - avatar
3 odpowiedzi
+ 5
int main() { int age; cin >>age; if (age == 16) { cout <<"Too young"; } if (age == 42) { cout << "Adult"; } if (age >= 60) { cout << "Senior"; }
18th Sep 2018, 2:13 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 2
This is because the age variable should be wrapped in double quotes(" ") while taking input It should be: cin >> age;
18th Sep 2018, 2:13 PM
Cool Codin
Cool Codin - avatar
0
thanks all for u answers
18th Sep 2018, 3:18 PM
shahul hameed aljas TA
shahul hameed aljas TA - avatar