C++20 sections · 1024 units
Open in Course

Semicolons

Ending each instruction

Every statement in C++ ends with a semicolon. The semicolon tells the compiler one instruction is finished and the next begins. Try deleting the semicolon after return 0. You will see an error pointing to the closing brace.

The compiler expected a semicolon but found a brace instead. Blank lines and spaces do not matter to the compiler. Semicolons define statement boundaries, not line breaks. You can write multiple statements on one line.