+ 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"; }
3 Antworten
+ 5
int main()
{
    int age;
    cin >>age;
    if (age == 16) {
        cout <<"Too young";
    }
    if (age == 42) {
        cout << "Adult";
    }
    if (age >= 60) {
        cout << "Senior";
    }
+ 2
This is because the age variable should be wrapped in double quotes(" ") while taking input
It should be:
cin >> age;
0
thanks all for u answers



