Chapter 5-Strings
Chapter 5-Strings
Example
int x = 10;
int y = 20;
int z = x + y; // z will be 30 (an integer)
Example
string x = "10";
string y = "20";
string z = x + y; // z will be 1020 (a string)
Example
string x = "10";
int y = 20;
string z = x + y;
Note: String indexes start with 0: [0] is the first character. [1] is the second character, etc.
Page | 5
Programming I June 2021
Example
string fullName;
cout << "Type your full name: ";
getline (cin, fullName);
cout << "Your name is: " << fullName;
Page | 6