1 |
h03 |
CS16 F16 |
Name: | ||||
---|---|---|---|---|
(as it would appear on official course roster) | ||||
Umail address: | @umail.ucsb.edu | section 9am or 10:30am |
||
Optional: name you wish to be called if different from name above. | ||||
Optional: name of "homework buddy" (leaving this blank signifies "I worked alone" |
h03: Homework 3
ready? | assigned | due | points |
---|---|---|---|
true | Thu 09/29 02:00PM | Tue 10/04 02:00PM |
You may collaborate on this homework with AT MOST one person, an optional "homework buddy".
MAY ONLY BE TURNED IN IN THE LECTURE/LAB LISTED ABOVE AS THE DUE DATE,
OR IF APPLICABLE, SUBMITTED ON GRADESCOPE. There is NO MAKEUP for missed assignments;
in place of that, we drop the three lowest scores (if you have zeros, those are the three lowest scores.)
Please:
- No Staples.
- No Paperclips.
- No folded down corners.
Read Chapter 2 (If you don’t have a copy of the textbook yet, there is one on reserve at the library under “COMP000-STAFF - Permanent Reserve”).
-
1. (2 pts) Show 2 different ways to initialize variables in C++?
2. (2 pts) Is this variable declaration statement in C++ a good one? Why or why not?
double union=30;
cout << "My dog likes to eat\t" << 5 << " cans of dog food a day" << " !" << endl;
#include <iostream>
int main()
int a(0),b(0),c(0);
string quote;
cout << "Enter 3 numbers separated by spaces: ";
cin >> a,b,c;
sum = a + b + c;
quote = "The sum of these 3 numbers is: ";
cout << quote << sum;
return 0; }
int x(35), y(5);
bool v, w;
v = (x >= y);
w = ((x/y) == 7);
cout << v << w << endl;