5------key2_06f[1] - Exam 2, 11/20/06 PIC 10A, Fall 2006...

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

View Full Document Right Arrow Icon
Page 1 Exam 2, 11/20/06 PIC 10A, Fall 2006 NAME: _________________________________________________ _____ Pascal _____ Nick 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 100 points on this exam. PAGE SCORE POSSIBLE 1 22 2 14 3 14 4 20 5 30 TOTAL 100 T 1.) [6 points] Briefly explain the difference between value and reference parameters. How are they differentiated in C++ syntax? For a value parameter, the compiler creates a local copy of the variable so any changes to that variable will not be reflected in the function that called it. A reference parameter passes the address of the variable, so any changes will be recorded. A value parameter is the default type for C++ 2.) [6 points] What does the srand function do and why is it useful? The srand function seeds the random number generator with a given integer, usually the current time. Without seeding, the function rand will produce the same list of numbers in the same order every time the program is run. 3.) [10 points] Convert the following if/else sequence to a switch statement.
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

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

Page1 / 16

5------key2_06f[1] - Exam 2, 11/20/06 PIC 10A, Fall 2006...

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

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