key1-1 - Exam 1 PIC 10A Fall 2007 KEY Check your TAs name...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Exam 1, 10/22/07 PIC 10A, Fall 2007 KEY Check your TA’s name: _____ 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
Background image of page 1

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

View Full DocumentRight Arrow Icon
1 1.) [2 points] Write a single cout statement that prints the text below. Frodo says: "I YOU!" (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 2 3 4 5 6 7 8 9 10 11 12 13 int main ( ) { cout << "Enter a phrase: "; string phrase; cin >> phrase; int x = 1; while (x <= phrase.length() ) { phrase.erase(x,1); phrase.insert(x,"*"); x = x+2;
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/28/2008 for the course PIC 10A taught by Professor Wittman during the Spring '08 term at UCLA.

Page1 / 6

key1-1 - Exam 1 PIC 10A Fall 2007 KEY Check your TAs name...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online