High: 100 (5)

Low: 20

Average: 71.5

 

Name: ______Key_________

 

Quiz 2 (Week 3)

CS-150, Fall ‘02, Dr. C. S. Tritt

 

Each question is worth the same amount.

 

  1. Which of the following is a valid C++ variable name?

 

a.       else – a keyword

b.      abc123

c.       123abc – begins with a digit

d.      abc$ – contains an illegal character

e.       #abc – contains an illegal character

 

  1. Which of the following is not a valid C++ variable name?

 

a.       _MyCount

b.      myCount

c.       my_count

d.      my count – contains a space

 

  1. Write the complete C++ statement you would use to create a variable called Weight that will hold the weight of a dozen eggs to the nearest hundredth of a pound.

 

double weight; // Weight of eggs in grams.

 

                        1st mistake –10, 2nd mistake –5, missing ; - 2 and including comment + 5.

 

  1. Evaluate the following C++ expression:

 

3 / 4 + 5 * 6 = 0 + 5 * 6 = 30

 

  1. Evaluate the following C++ expression:

 

6. + 5. / 4. - 3. = 6. + 1.25 – 3 = 4.25

 

Math errors on problems 4 and 5 were –2.