1 |
h03 |
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") |
h03: Homework 3: Basic C++
ready? | assigned | due | points |
---|---|---|---|
true | Tue 04/11 12:00PM | Thu 04/13 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 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.)
Please:
- No Staples.
- No Paperclips.
- No folded down corners.
Read Chapter 2 (If you do not have a copy of the textbook yet, there is one on reserve at the library under “COMP000-STAFF - Permanent Reserve”). ALL YOUR ANSWERS MUST BE WRITTEN ON THIS PAPER - DO NOT TURN IN ANY EXTRA PAPERS!
-
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 maguro=50;
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;