String Concatenation in C++

Level 286 keystrokes

Joins two strings and a space with the + operator and prints Hello World.

C++ code

// Stores "Hello" in first
1string first = "Hello";
// Stores "World" in second
2string second = "World";
// + on strings creates a new joined string; " " adds the space between the words
// first + " " is evaluated first and gives a string, then second is added
3cout << first + " " + second << endl;

Output

Hello World
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this C++ code and how often they appear.

  • "× 6
  • <× 4
  • ;× 3
  • +× 2
  • =× 2

More C++ examples at level 2

← C++ typing practice