Test yourself on everything in the course: printing, variables, arithmetic, decisions and loops.
1. What does std::cout << "A" << std::endl << "B"; print?
std::cout << "A" << std::endl << "B";
A B
AB
Aendl B
A
B
2. Which lines declare a whole number variable count that starts at 0?
count
count int = 0;
int count{0};
int count{0.5};
int count{};
int count = 0;
3. What is the value of 2 + 3 * 4?
2 + 3 * 4
4. What is the value of 10 % 4?
10 % 4
5. What does std::cout << 10 / 4.0; print?
std::cout << 10 / 4.0;
2.5
2
3
2.0
6. With x equal to 15, which conditions are true?
x
x > 10 && x < 20
x == 10
x < 10 || x > 12
x % 5 == 0
x <= 14
7. What happens to the cases below a matching case that has no break?
case
break
default
8. Which type stores a single character such as 'y'?
'y'
9. What does for (int i = 1; i <= 4; ++i) { if (i == 2) { continue; } std::cout << i; } print?
for (int i = 1; i <= 4; ++i) { if (i == 2) { continue; } std::cout << i; }
1234
1
34
134
10. What does int n = 4; int total{}; while (n > 0) { total += n; --n; } std::cout << total; print?
int n = 4; int total{}; while (n > 0) { total += n; --n; } std::cout << total;
11. What does const int limit{10}; limit = 20; do?
const int limit{10}; limit = 20;
limit
const
12. What does std::cout << (5 == 5); print?
std::cout << (5 == 5);