Name_______________________
Login___________________SID________
CS 010: Introduction to
Computer Science I
Quiz 2: 10 minutes
- A
description of steps to solve a problem that is unambiguous, executable,
and terminating is called ___________________?
- a
library
- an algorithm
- a
statement
- an
expression
- Pseudocode is a mixture of programming code and
English used to describe the steps mentioned in question 1.
- TRUE
- FALSE
- Which
C++ expression is equivalent to the following math equation?
a.
a * a * (x + y) / (y + 1)
b.
a ^ 2 * (x + y) / y + 1
c.
(a * a * (x + y)) / (y + 1)
d.
A
and C
e.
All of the above
f.
None of the above
- What
is the value of the following expression if x is an integer variable and
has a value that is odd (i.e., 1, 3, 5, 7, …)?
x % 2
a.
0
b.
1
c.
2
d.
cannot be determined from the given information
- What
will be output by the following statements?
string greeting =
"Hello World!\n";
cout <<
greeting.substr(6,2)
<< greeting.substr(6,1)
<< greeting.substr(11,1);
a.
Hello
b.
World!
c.
WoW!
d.
W
- What
is the value of s after the following statements?
string first_name = “Kris”;
string last_name = “Miller”;
string s = first_name.substr(0,1)
+ last_name.substr(1,5);
a.
Kris Miller
b.
KrisMiller
c.
KMiller
d.
KrisM
e.
Killer
f.
None of the above
- Which
expression has the value 10 given the following statements?
string s1 = “Hello”;
string s2 = “World”;
string s3 = s1 + “ “ + s2;
- s1.length()
- s2.length()
- s3.length()
- s1.length() + s2.length()
- C
and D
- None
of the above
- What
is output and what is the value of x after the following statements?
double x = 5.66667;
cout << fixed <<
setprecision(3) << x;
- Output:
5.67, value of x: 5.67
- Output:
5.667, value of x: 5.667
- Output: 5.667, value of x:
5.66667
- Output:
5.66667, value of x: 5.667
- Output:
5.66667, value of x: 5.66667
- None
of the above
- Which
of the following is an example of a literal?
- 10
- 4.5
- “count”
- count
- All except D are examples
of literals
- None
of the above are examples of literals
- The
following statement has what kind of error?
cout << “hello;
- Syntax or compile-time
error
- Logic
error
- Runtime
error
- There
is no error in this statement