DOC PREVIEW
UVA CS 101 - PLEDGED

This preview shows page 1-2-3-4 out of 11 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS101 PLEDGED SPRING 2001CS 101 PLEDGED PAGE 1 OF 11The following exam is pledged. All answers are to be given on the provided answer sheet. The test isclosed book, closed note, and closed calculator. If you believe more than one answer is acceptable,choose the best answer. YOU MUST HAND IN ALL COPIES OF THE TEST AND THE ANSWERSHEET. All questions can be assumed to compile except possibly 52-54. However, not all possibleanswers necessarily compile. Leaving out or misentering identification information on the answersheet will cause a 5 point penalty.PART I: Multiple choice questions1. Give the decimal value of the number 010012.(a) 1001(b) 5(c) 9(d) 17(e) none of the above2. Give the decimal value of the number 03748(a) 374(b) 252(c) 352(d) 254(e) none of the above3. Give the base 2 representation of the decimal number 126.(a) 000011112(b) 011111102(c) 011000102(d) 111111102(e) none of the above4. Give the base 2 representation of the decimal number -17.(a) 111111112(b) 111011112(c) 100012(d) –100012(e) none of the above5. What is the length of the literal character string "1\t2\t2"?(a) 3(b) 5(c) 7(d) 9(e) none of the aboveCS101 PLEDGED SPRING 2001CS 101 PLEDGED PAGE 2 OF 116. What does the following program output? (a) We will not suffernaloneendl(b) We will not suffernalone.(c) We will not suffer alone.(d) We will not sufferalone.(e) None of the above7. Why do programmers comment?(a) Give compiler extra instructions(b) Aid readability(c) To hide code for debugging purposes(d) (b) and (c)(e) none of the above8. What statement produces the output(a) cout << "Triangle" << "sides:" << "3" << endl;(b) cout << "Triangle sides: 3" << endl;(c) cout << "Triangle sides:" << 3 << endl;(d) (a), (b), and (c)(e) none of the above9. What statement defines a single-precision floating point C++ constant LIGHT_SPEED equal to3.0⋅106?(a) final float LIGHT_SPEED = 3.0e6; (b) const double LIGHT_SPEED = 3.0e6;(c) constant float LIGHT_SPEED = 3.0e6;(d) const float LIGHT_SPEED = 3.0e6;(e) none of the above10. What statement defines a double variable area that is initialized to the area of a rectangle withwidth w and height h?(a) double area = cin >> w * h;(b) double area = w + h;(c) double area, w, h;(d) double area = w * h;(e) none of the above#include <iostream>using namespace std;int main () {cout << "We will not suffer\nalone." << endl;return 0;}Triangle sides: 3CS101 PLEDGED SPRING 2001CS 101 PLEDGED PAGE 3 OF 1111. Which choice uses parentheses that explicitly demonstrate how the following expression is evaluated? (a) (8 + (5 * (6 / 4))) - 2 (b) (8 + ((5 * 6) / 4)) - 2 (c) (((8 + 5) * 6) / 4) - 2 (d) (8 + (5 * 6)) / (4 - 2) (e) none of the above12. Evaluate the following C++ expressions. (a) 0, 1, 1.25(b) 1, 1, 1.25(c) 1, 1.0, 1.25(d) 1, 1.25, 1.25(e) none of the above13. Evaluate the following C++ expression. (a) 12(b) 12.0(c) 12.5(d) 12.75(e) none of the above14. Write a C++ expression for the mathematical expression .(a) a*a*a*(a+1)*(a-7)(b) a^3(a+1)(a-7)(c) a**3(a+1)*(a-7)(d) (a) and (b)(e) none of the above15. Write a C++ expression for the mathematical expression .(a) (1+x*x)e-1(b) 1/(1 + x*x)(c) 1/(1 + 1/(x*x))(d) (a) and (c)(e) none of the above8 + 5 * 6 / 4 - 213 % 35 / 45 / 4.01.5 * 3.0 + 8 + 2 / 8 a3a 1+()a 7–()11 x2+--------------CS101 PLEDGED SPRING 2001CS 101 PLEDGED PAGE 4 OF 1116. Suppose water costs 0.021 cents per 100 gallons. Write a single statement that defines a single-preci-sion floating point value total that is initialized to the cost in cents of buying n gallons of water. (a) float total = 0.021F * n / 100;(b) float total = 2.1e-1 * n / 100;(c) float total = 0.021F * n / 10e-2;(d) float total = 0.021F * n * 10e+2;(e) none of the above17. Suppose int variables a, b, and c are int variables initialized respectively to 1, 2, and 3. What val-ues are assigned to e, f, and g after the following code segment has completed.(a) e is 1, f is 2, g is 4(b) e is 1, f is 3, g is 5(c) e is 2, f is 2, g is 4(d) e is 2, f is 3, g is 5(e) none of the above18. Which statement best converts a centigrade temperature to its equivalent Fahrenheit temperature,where the equation for converting a Celsius temperature to Fahrenheit is. You may assume that double variables Fahrenheit and Cel-sius are already defined(a) Fahrenheit = 9 * Celsius / 5 + 32;(b) Fahrenheit = 9 / 5 * Celsius + 32;(c) Fahrenheit = 9 / 5 * (Celsius + 32);(d) (a) and (b) work equally well(e) none of the above19. Define a string variable s that represents the concatenation of the string variables u and v. Youmay assume that u and v have been previously defined.(a) string s = u || v;(b) string s = u + v;(c) string s = u && v;(d) string s = u concatenate v;(e) none of the above20. Give a code segment that defines an EzWindows window with the label "CS 101". The windowshould be 12 centimeters wide and 10 centimeters high.(a) Window W = "CS 101";(b) Window W("CS 101", 12, 10);(c) SimpleWindow W("CS 101", 12, 10);(d) W = SimpleWindow("CS 101", 12, 10);(e) none of the aboveint e = ++a;int f = b++;int g = ++c + 1;Fahrenheit95---Celsius 32+=CS101 PLEDGED SPRING 2001CS 101 PLEDGED PAGE 5 OF 1121. Define a string variable whose value is the empty string.(a) string s;(b) string s = "";(c) string s = '';(d) string s = " ";(e) none of the above22. What appears in your program output window from the following code segment?.(a) 1(b) "1"(c) s(d) "s"(e) none of the above23. An abstraction is(a) object(b) representation of the essential attributes and behaviors of a type of information(c) variable(d) all of the above(e) none of the above24. How many of bits of memory are there in a machine with 64 megawords of memory where a wordconsists of 4 bytes?(a) 4 * 64 * 1,000,000(b) 4 * 64 * 220(c) 8 * 4 * 64 * 27(d) 8 * 4 * 64 * 220(e) none of the aboveQuestions 25–27 are concerned with the following code segment. string s = "1";cout << s << endl;if (i == j) {cout << "A" << endl;}else if ((i % j) < 3) {cout << "B" << endl;}else if (i < (j-1)) {cout << "C" << endl;}else {cout << "D" << endl;}CS101 PLEDGED SPRING 2001CS 101 PLEDGED PAGE 6 OF 1125. If i is 9 and j is 4, what is the output?(a) A(b) B(c) C(d) D(e) none of the above26. If i is 5 and j is 6, what is the output?(a) A(b) B(c) C(d) D(e) none of the above27. If i is 4 and j is 9, what is the output?(a) A(b) B(c) C(d) D(e) none of the aboveQuestions 28-29 are concerned with how many times the phrase CS101 rocks is displayed by the followingcode segment.int number;while (cin >> number)


View Full Document

UVA CS 101 - PLEDGED

Documents in this Course
Classes

Classes

53 pages

Recursion

Recursion

15 pages

Iteration

Iteration

88 pages

PLEDGED

PLEDGED

6 pages

Objects

Objects

33 pages

CS 101

CS 101

42 pages

Classes

Classes

83 pages

Iteration

Iteration

92 pages

Classes

Classes

186 pages

Classes

Classes

208 pages

Hardware

Hardware

21 pages

Arrays

Arrays

70 pages

Load more
Download PLEDGED
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view PLEDGED and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view PLEDGED 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?