Name:_____________________
SID (Last
4):_____________________
Login:
_____________________
CS 10 - Fall
2004
Final
Be sure to read each problem carefully and follow the directions. Points may be taken off if you do not follow the directions. For example, if the problem asks you to write code or a statement, do not write an entire program. Please feel free to ask if you have any questions. Illegible answers will not be graded.
You will not be graded on commenting. You do not need to write any comments. If, however, you do something strange that you think may be hard for the grader to figure out what you are doing, you may want to comment that part. Partial credit will be given. You will also not be graded on error checking unless specifically asked to do so.
Please work wisely. Do not spend too much time on any one problem.
You will be required to show your student ID when you hand in your exam.
|
Problem 1 - 50 |
65 |
|
|
Problem 51 |
5 |
|
|
Problem 52 |
15 |
|
|
Problem 53 |
15 |
|
|
|
|
|
TOTAL POINTS = 100
Mark a for TRUE and mark b for FALSE. (1.3 pts
each)
FALSE
TRUE
FALSE
FALSE
FALSE
FALSE
TRUE
FALSE
FALSE
TRUE
FALSE
FALSE
TRUE
Multiple Choice. (1.3 pts each)
a. ALU
b. Input Unit
c. Memory Unit
d.
Operating
System
e. Secondary Storage Unit
a.
High-level
language
b. Assembly language
c. Machine language
Point (10, 0);
move(-2.5, -3);
Point p1(14, 22);
Point p2 = p1;
Point p3(p1.get_x(), p2.get_y());
Point dot(rand() % 21 10, 0);
const int A = 5;
A = 10;
int b;
cout << b;
int a, b;
cout << Enter 2 numbers:;
cin >> a, b;
string s = Hello;
s = s + s;
int i = 3;
int j = 13;
int k = 30;
(i != j) && (((i < 5) || (j < 10)) && (k >= 30))
a.
true
b. false
c. invalid condition
int a = 1;
int b = 0;
bool test1 = true;
bool test2 = false;
!test1 || !(a > b && test2)
a.
true
b. false
c. invalid condition
!(a == b || c <= d)
int x = 1;
int a = 3;
if (x < 0)
a++;
else if (x == 1)
a++;
else if (x > 0)
a++;
cout << a;
a. 3
b.
4
c. 5
d. 6
e. None of the above
int x = 1;
int a = 3;
if (x < 0)
a++;
if (x == 1)
a++;
if (x > 0)
a++;
cout << a;
a. 3
b. 4
c.
5
d. 6
e. None of the above

a % 2
a + b * c d
a % b * c
int x = 0;
for (int i = 0; i < 10; i = i + 2)
{
x = x + i;
cout << x << ;
}
int x = 1;
while ( x < 5 )
{
x++;
}
cout << x;
double x = 10.0;
int count = 0;
do
{
x = x / 2.0;
count++;
} while (x > 2.0);
cout << count;
void f(int &a, int b, int c);
Use the following code for the next 2 questions. Read both questions before tracing the code.
for (int i = 0; i < 3; i++ )
{
int x = 0;
for (int j = 0; j < 3; j++)
{
if ( (i * j) % 2 == 0 )
{
x = x + (i * j);
cout << x;
}
}
}