Role of Semicolon in C:
- Semicolons are end statements in C.
- The Semicolon tells that the current statement has been terminated and other statements following are new statements.
- Usage of Semicolon in C will remove ambiguity and confusion while looking at the code.
- They are not used in between the control flow statements but are used in separating the conditions in looping.
for(initialization/declaration;
condition;
increment/decrements)
{
// body
}
Role of Semicolon in Java:
- Java uses Semicolon similar to C.
- Semicolon is a part of syntax in Java.
- It shows the compiler where an instruction ends and where the next instruction begins.
- Semicolon allows the java program to be written in one line or multiple lines, by letting the compiler know where to end the instructions
Role of Semicolon in C++:
- Semicolon is a command in C++.
- The Semicolon lets the compiler know that it’s reached the end of a command.
- Semicolon is often used to delimit one bit of C++ source code, indicating it’s intentionally separated from the respective code.
- Usage of Semicolon in C++ is after class and structure definitions, variable declarations, function declarations, after each statement generally.