Skip to content

Commit 04b8351

Browse files
committedDec 29, 2021
Forgot about the quiz.
1 parent c6aefd0 commit 04b8351

File tree

1 file changed

+98
-0
lines changed
  • Section08-Statements_and_Operators/section08_quiz

1 file changed

+98
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
1. The ________ operator increments the value of its operand by one then uses the value.
2+
- [x] prefix increment
3+
- [ ] postfix increment
4+
- [ ] prefix decrement
5+
- [ ] postfix decrement
6+
7+
2. The operator used to test two operands for equality is ________ .
8+
- [ ] equals
9+
- [ ] compare
10+
- [x] ==
11+
- [ ] =
12+
13+
3. The operator that represents logical AND is ________ .
14+
- [ ] &
15+
- [ ] ||
16+
- [ ] |
17+
- [x] &&
18+
19+
4. The operator that represents logical OR is ________ .
20+
- [ ] &
21+
- [x] ||
22+
- [ ] |
23+
- [ ] &&
24+
25+
5. If a is 3, b is 5, and c is 7, which of the following are true?
26+
27+
```c++
28+
b == 5;
29+
c == (a + b) - 1;
30+
b > 5;
31+
a >= 3;
32+
c <= (a * b) / a;
33+
```
34+
35+
- [ ] 1, 2, and 3 are true
36+
- [x] 1, 2, and 4 are ture
37+
- [ ] Only 1 is true
38+
- [ ] All are true
39+
40+
6. `a < 10` is called a(n) ________ .
41+
- [ ] statement
42+
- [ ] declaration
43+
- [x] relational expression
44+
- [ ] unary expression
45+
*I got this one wrong!! I thought it was a "statement"*
46+
47+
7. What will the following code display?
48+
49+
```c++
50+
int x = 10, y = 3, z = 6;
51+
cout << (x == y) << " ";
52+
cout << (z <= x) << " ";
53+
cout << (y != z) << " ";
54+
cout << (x > y && z < x) << " ";
55+
cout << (y < x && z < x) << " ";
56+
cout << (x < y || z < 0 ) << endl;
57+
```
58+
- [ ] 010101
59+
- [ ] 011010
60+
- [ ] 100001
61+
- [x] 011110
62+
63+
8. What is displayed by the following code?
64+
```c++
65+
int amout = 100;
66+
amount += amount * 2
67+
cout << amout << endl;
68+
```
69+
70+
- [ ] 102
71+
- [ ] 202
72+
- [ ] 200
73+
- [x] 300
74+
75+
9. What is displayed by the following code?
76+
```c++
77+
int x = 5;
78+
int y = -2;
79+
int z = 2;
80+
cout << (x + y * z <= x + z * z - x) << endl;
81+
```
82+
- [x] 1
83+
- [ ] 0
84+
- [ ] -1
85+
- [ ] It won't compile
86+
87+
10. What are the values of x and y after the follwing code executes?
88+
```c++
89+
double a = 100;
90+
int b = 12;
91+
int x = b %3;
92+
double y = a / b;
93+
int z = a / b;
94+
```
95+
- [ ] x = 0, y = 8, z = 8
96+
- [ ] x = 4, y = 8.3333333 and z = 8
97+
- [ ] x = 8, y = 8.3333333 and z = 8
98+
- [x] x = 0, y = 8.3333333 and z = 8

0 commit comments

Comments
 (0)