See the bottom on how to submit your work.
Due: Before 0800 on next class day
- [10 pts] Read today's lecture notes. Honestly declare how you read
the notes.
- (10 pts) I read the notes carefully. I have a good understanding of the topics therein.
- (10 pts) I read the notes carefully, but I don't really understand the following points well:
- (0 pts) I didn't read the notes carefully.
- [10pts] For each of the below, circle whether it is an expression, statement or
neither.
| expression / statement / neither | double x;
|
| expression / statement / neither | 3 / x
|
| expression / statement / neither | y = x*5
|
| expression / statement / neither | 4 + x /
|
| expression / statement / neither | x = 4;
|
- [18pts] Assume the following declarations. Fill in the table with the type
and values for the given expressions.
double a;
int b;
char c;
a = 16.4;
b = 3;
c = 4*a + b;
|
|
| expression | type | value |
a + b | | |
'a'+ b | | |
'b'-'a' | | |
a / 4 | | |
b / 4 | | |
b % 4 | | |
c | | |
int(c) | | |
b = a | | |
|
- [4pts] What is the output of the following code?
cout << (2.5*4)/5 << endl << 2.5*(4/5) << endl;
- [4pts] With super vision you look into your computer and see
that a particular byte in memory has contents
00101010.
-
If we interpret that byte as a
char, what character does it represent?
-
If we interpret that byte as a
bool, what value does it represent?
- [54pts] Write a program hw.cpp that reads in a 3-letter word in uppercase
letters and prints out the same word with lowercase letters.
A typical run of the program should look like this (user input colored red):
Input a 3-letter word in uppercase letters: CAT
Output: cat
Hint: look at the ASCII table and think about how to go from the
ASCII value of a uppercase letter to the ASCII value of the same letter in
lowercase.
Turn in (Due: 0800 on the next class day)