← C++ from Scratch
Lesson 4 of 62 · 10 XP
Comments
Theory and problem statement
Machine translation, not yet reviewed by a native speaker.
The compiler skips comments — they're for people:
// single-line: to the end of the line
/* multi-line:
can span several lines */
int hp = 100; // the hero's health
A good comment explains why, not what: i++; // increase i is useless,
// enemies spawn in waves of 5, otherwise the game lags on weak PCs is useful.
A comment is a handy way to temporarily "switch off" a line of code while debugging.
Task. The program has three outputs, but one is extra — it breaks the result. Comment it out, without deleting it, so that the program prints:
Start
Finish
Sign up for free to solve this task right in your browser: code editor, running, test checks and hints.