3-----key1[1] - Exam 1, 10/22/07 PIC 10A, Fall 2007 KEY...

Page 1 Exam 1, 10/22/07 PIC 10A, Fall 2007 KEY _____ Cau _____ Ryan _____ Jacob _____ Michael You have 50 minutes to complete this exam. You are not allowed to use any books, notes, calculators, or electronic devices. Write your answers carefully. Incomplete, unintelligible, or illegible answers will receive little or no credit. When you are asked to write a program, it is not necessary to comment your code but you are expected to indent appropriately to make your code easier to follow. There are a total of 50 points on this exam. PAGE SCORE POSSIBLE 1 8 2 8 3 10 4 12 5 12 TOTAL 50 T 1.) [2 points] Write a single cout statement that prints the text below. Frodo says: (Hint: The heart is given by the escape character \3.) cout << "Frodo says:\n\"I \3 YOU!\"" 2.) [6 points] The following program is supposed to get an input phrase from the user and replace every other character with an asterisk *, starting with the second letter. So the phrase "LORD OF THE RINGS" becomes "L*R* *F*T*E*R*N*G*". The program compiles, but does not seem to run correctly. 1 int main ( ) { 2 cout << "Enter a phrase: " 3 string phrase 4 cin >> phrase 5 int x = 1 6 while (x <= phrase.length() ) { Check your TAhs name: I . YOU!

This preview
has intentionally blurred sections.
Sign up to view the full version.