How the test works
The test after topic 6 checks topics 1–6: variables and arithmetic, conditions and loops, code culture and debugging, functions with contracts, and arrays with searching. This lesson is practice in the same shape.
Two parts
- Questions. Short code: what it prints, where the bug is, how many times a loop runs. You answer on your own, without a compiler. There are twelve here, each with an answer and an explanation.
- Programs. Two small tasks in the
test/1/folder:numbers.candrising.c. Autotests check them, like the homework.
How long the real test takes and what you may use will be announced by your lecturer. Practice has no time limit, but try to write both tasks within an hour: that's a good sign you are ready.
How to check the programs
The task descriptions and the exact output text are in steps 4 and 5 and in the test/1/tests/ files. Run the tests like this:
ctest --preset debug -L test1
In CLion: the All CTest configuration and ▶. Both files already have the #includes and main; while they are empty, the tests fail.
These tasks give no points: GitHub Actions builds and runs them, but "Points" doesn't count them. They are for checking yourself.
What is checked, same as in the homework
- the program builds without warnings (
-Wall -Wextra -Werror -pedantic -Wvla); - the output matches the expected text letter by letter;
- each part is a function with a contract and an
assert, andmainonly calls them; - no
TODOis left.
If you get stuck, go back to the topic the question comes from: every answer says which topic it belongs to.