| Strings Worksheet #2 | Name - |
| Day of Week - |
1. (True/False) The string "abc" is considered to be less
than the string "xyz"
2. (True/False) The string "abc" is considered to be less
than the string "ABC"
3. (True/False) The string "John" is considered to be equal
to the expression "Jo" + "hn"
4. (True/False) If the string variable firstName contains the string "Jane"
then the statement cout << firstName.length(); will display the value 4.
5. Write an if statement that displays the message "greater than"
if the string variable player1 is alphabetically greater than the string variable player2 .
|
6. Write a statement displays the sum of the length of the string variable firstName plus the length of the string variable lastName.
7. Write an assignment statement that concatenates the string variables firstName and lastName with an added blank space between them and stores the resulting string value
into the string variable wholeName. This answer should not use cout in any way since you are not supposed to display anything.
8. Write a program that allows the user to input his first name and then uses
a loop to display each letter of the name on a separate line of output.
9. Write a program that allows 3 people to input their first names and then displays the name that is least alphabetically (e.g. Alice is less than Bill). Use the back of the paper if necessary.