cs10final_03fal_sol

cs10final_03fal_sol - UCR CS010 Fall 2003 Introduction to...

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

View Full Document Right Arrow Icon
UCR CS010 Fall 2003 Introduction to Computer Science I Kris Miller, Dr. Brian Linard Final Time: 170 minutes 1. In C++ only one of the following is a valid indentifier (i.e. can be used as a name for a variable or function, etc.). Which is it? a. number-of-elements b. break c. TOOMUCH d. 2fast e. 2. Before a variable can be used in C++ it must be: a. declared b. initialized c. inserted into a namespace d. referenced in the header 3. What is the value of x after the following statements? int x; x = x + 30; a. 0 b. 33 c. 30 d. garbage 4. What is the value of x after the following statements? double x; x = 15/4; a. 3.75 b. 4.0 c. 3.0 d. 60
Background image of page 1

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

View Full DocumentRight Arrow Icon
5. What is the value of x after the following statements? int x; x = 15%4; a. 15 b. 3 c. 4 d. 3.75 6. Given the following code fragment, what is the final value of y? int x, y; x = -1; y = 0; while(x < 3) { x += 1; y += 2; } a. 8 b. 10 c. 6 d. 4 7. Given the following code fragment, what is the output? int x=5; if( x > 5) cout << "x is bigger than 5. "; cout <<"That is all. "; cout << "Goodbye\n"; a. x is bigger than 5. That is all b. x is bigger than 5 c. That is all. Goodbye d. Goodbye 8. Executing one or more statements one or more times is known as: a. selection b. iteration c. sequence d. algorithm
Background image of page 2
9. Assuming num1, num2, and num3 have been declared and initialized as variables of type int, which of the following is a correct function call for the following function declaration? void product_output(int n1, int n2, int n3); a. void product_output(int num1, int num2, int num3); b. void product_output(num1, num2, num3); c. product_output(num1, num2, num3); d. output = product_output(num1, num2, num3); e. void output = product_output(num1, num2, num3); 10. What is wrong with the following function definition? { cost = cost + ( tax_rate / 100.0 ) * cost; } a. The formal parameter, cost, should be pass-by-value, not pass-by-reference. b. The formal parameter, tax_rate, should be pass-by-reference, not pass-by-value. c. The function does not have a return statement. d. You cannot have a pass-by-value parameter and a pass-by-reference parameter in the same function definition. e. None of the above. 11. What is wrong with the following function definition? void print_output(int score, char grade) { void print_header() { cout << “score grade” << “------ -------“; } print_header(); cout << score << “ “ << grade; } a. The variable score should be a double, not an int. b.
Background image of page 3

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

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

Page1 / 10

cs10final_03fal_sol - UCR CS010 Fall 2003 Introduction to...

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

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