What is wrong???

What is wring with the code over here and how do I fix it.
I am a beginner and I use Code::Blocks


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 #include <iostream>

using namespace std;

int main()

{

int a;
int b;
int c;
    cout << "Welcome to The portal which can do many powerful things" << endl;
    cout << "What is your age" <<endl;
    cin >> a;
    cout << " You are old enough to do this" <<endl;
    cout << "What is your name" <<endl;
    cin >> b;
    cout << "Hello" b <<endl;

    return 0;
}
b is an int, but it looks like you intended it to be a string.
See "Introduction to strings" here:
http://www.cplusplus.com/doc/tutorial/variables/

there's a << operator missing on line 18. The compiler should have issued a message about that.
you cannot concatenate a string and a variable without using insertion operator in cout
closed account (j1CpDjzh)
b needs to be a string. Also, I recommend using getline(cin, b); for strings. However, that's just my cup of tea haha.

Also, line 18 should be cout << "Hello" << b << endl; in order to display output.
Last edited on
Topic archived. No new replies allowed.