---
title: "Purpose of semicolon"
subject: "Computer Programming"
chapter: 3
key: "semester_1/computer_programming:semicolon-purpose"
source: https://www.bctengineer.com/q/semester_1/computer_programming/semicolon-purpose
site: BCT Engineering
---

# Purpose of semicolon

Computer Programming · Chapter 3: Introduction to ‘C’ programming

- Asked in: 2073 Shrawan, 2 marks
- Video: [Semicolons - C Programming](https://www.youtube.com/watch?v=ctZJ_7YxD_g) — Sonar Systems
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_1/computer_programming/semicolon-purpose
- Whole chapter: https://www.bctengineer.com/md/semester_1/computer_programming/chapter-3

## Question

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

## 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.

## Answer

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 ...".

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What is the purpose of the semicolon in C?
   A. It marks the end of a statement
   B. It starts a comment
   C. It separates function arguments
   D. It declares a variable
   Answer: A. The semicolon is the statement terminator. (Key point: Terminator)

2. What happens if a semicolon is omitted?
   A. The compiler ignores it
   B. The compiler joins it with the next statement and gives a syntax error
   C. The program runs twice
   D. A warning only at run time
   Answer: B. The compiler cannot tell where the statement ends and reports a syntax error. (Key point: Missing semicolon)

3. Can x = 5; y = x + 2; be on one line?
   A. No, one statement per line
   B. Yes, semicolons separate the two statements
   C. Only inside loops
   D. Only with braces
   Answer: B. The semicolons mark each statement end so several can share a line. (Key point: Multiple statements)

## Related in Computer Programming

- [Purpose of continue statement](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Acontinue-purpose) — Computer Programming, chapter 5
