Skip to main content

Purpose of semicolon

Short answer

In C, the semicolon (;) is a statement terminator. It marks the end of a statement, allowing the compiler to distinguish where one statement ends and the next begins. Omitting it causes a syntax error.

What is the purpose of the semicolon that appears at the end of most assignment statements in C?

In C, the semicolon ; is the statement terminator. It marks the end of a statement, so the compiler knows where one statement stops and the next begins. For example, x = 5; y = x + 2; are two statements on one line.

If it is omitted, the compiler joins the statement with the next one and gives a syntax error such as "expected ';' before ...".

✓ Answer checked by Claude Opus 5.5 (high effort)

All Computer Programming chapter 3 questions →