Name_______________________
Login___________________SID________
CS 010: Introduction to
Computer Science I
Quiz 2: 10 minutes
- What
is output by the following statement provided all needed libraries were
included?
cout << fixed <<
setprecision(2) << 20 / 8;
a.
2.5
b.
2.50
c.
2
d.
2.0
e.
4
f.
there is a syntax error
- What
is output by the following statement provided all needed libraries were
included?
cout << fixed <<
setprecision(2) << 20 % 8;
a.
2.5
b.
2.50
c.
2
d.
2.0
e.
4
f.
there is a syntax error
- What
is output by the following statement provided all needed libraries were
included?
cout <<
fixed << setprecision(2) << 20.0 / 8;
a.
2.5
b.
2.50
c.
2
d.
2.0
e.
4
f.
there is a syntax error
- What
is output by the following statement provided all needed libraries were
included?
cout <<
fixed << setprecision(2) << 20.0 % 8;
a.
2.5
b.
2.50
c.
2
d.
2.0
e.
4
f.
there
is a syntax or compile-time error
- Strings
are a built-in or fundamental data type of C++.
- TRUE
- FALSE
- What
is output by the following statements?
int x = 10;
20 = x;
cout << x;
- 10
- 20
- x
- 10.0
- 20.0
- there is a syntax error
- Which
C++ expression below is a valid translation of the following algebraic
expression?
- a^2
(b 1) / (b + 1) (c / d)
- a^2
* ((b 1) / (b + 1)) (c / d)
- a
* a * b 1 / b + 1 c / d
- a * a * (b 1) / (b + 1)
c / d
- B
and D
- None
of the above.
- What
is output by the following statements?
string str1 = hello!;
string str2 = jumble;
cout << str2.substr(0,1)
<< str1.substr(5,1);
- jello!
- humble
- j!
- ello!
- jumblehello!
- none
of the above
- What
is the value of x after the following statements?
double x = 4.5678
cout << fixed <<
setprecision(2);
- 4.5678
- 4.56
- 4.57
- 4.5
- 4.6
- none
of the above
- Any sequence or combination of space and newline
characters are considered white space in C++.
- TRUE
- FALSE