1 |
h04 |
CS16 S17 |
Name: | ||||
---|---|---|---|---|
(as it would appear on official course roster) | ||||
Umail address: | @umail.ucsb.edu | |||
Optional: name you wish to be called if different from name above. | ||||
Optional: name of "homework buddy" (leaving this blank signifies "I worked alone") |
h04: Homework 4: Flow Control and Loops in C++
ready? | assigned | due | points |
---|---|---|---|
true | Thu 04/13 12:30PM | Tue 04/18 12:30PM |
You may collaborate on this homework with AT MOST one person, an optional "homework buddy".
MAY ONLY BE TURNED IN IN THE LECTURE LISTED ABOVE AS THE DUE DATE. There is NO MAKEUP for missed assignments.
In place of that, we drop the two lowest scores (if you have zeros, those are the two lowest scores.)
Read Chapter 2 and Ch 3 (If you do not have a copy of the textbook yet, there is one on reserve at the library under “COMP000-STAFF - Permanent Reserve”).
PLEASE MARK YOUR HOMEWORK CLEARLY, REGARDLESS OF IF YOU WRITE IT OUT IN INK OR PENCIL!
-
1. (1 pts) Which Boolean operator, when used with 2 logic expressions, yields TRUE if either expression is TRUE?
2. (1 pts) What is wrong (if anything) with this C++ expression?
if (size = 9)
cout << "The size is too small";
int x = 20;
while ( x > 0) {
cout << x << endl;
x = x – 4;
}
COUNTDOWN TO ZERO: 10
COUNTDOWN TO ZERO: 9
...
COUNTDOWN TO ZERO: 1
COUNTDOWN TO ZERO: LIFT OFF!
a) (x == 6)
b) ((x == 6) || (y < 20))
d) ((!(x < z) || (y > z)) && (z == 12) && (y == 10))
.
int s = 1;
do
cout << s << " ";
while (s++ <= 5);
while (++s <= 5);