CMPSC 101 - Strings Worksheet #1 Name -

1. Write a statement that displays the value contained in the string variable named userName.

 

2. Write a statement that displays the value contained in the string variable firstName followed by a single blank space and then the value contained in the string variable lastName.

 

3. Write a statement that displays the first character of the string variable firstName followed by a new line (endl)?

 

4. Write an initialization statement that declares a string variable named courseName and initializes it to the string literal "CMPSC 101".

 

5. Write an assignment statement that assigns the string value "CMPSC 203" to the string variable courseName.

 

6. Write a full C++ program that asks the user to input his first name and then asks the user to input his last name. The program should then display the user's first and last initials separated by a single space.

 

 

 

 

 

 

 

7. Write a full C++ program that asks the user to input his last name. The program should then print the last letter of the user's last name. (Hint: You should use the length function.) Write your program on the back of the paper if necessary.