Strings Worksheet #1 Name -
  Day of Week -

1. Write a declaration statement that declares a string variable named courseName and that initializes it to the string literal "CMPSC 101".


2. Write a statement that displays the word or phrase that is stored in the string variable named courseName.

 

3. Write a statement that displays the value contained in the string variable courseName followed by the phrase " is the best course ever" on the same line of output.

 

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


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.