Role of SemiColon in various Programming Languages

Role of Semicolon in C: 

  1. Semicolons are end statements in C.
  2. The Semicolon tells that the current statement has been terminated and other statements following are new statements.
  3. Usage of Semicolon in C will remove ambiguity and confusion while looking at the code.
  4. 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: 

  1. Java uses Semicolon similar to C.
  2. Semicolon is a part of syntax in Java.
  3. It shows the compiler where an instruction ends and where the next instruction begins.
  4. 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++: 

  1. Semicolon is a command in C++.
  2. The Semicolon lets the compiler know that it’s reached the end of a command.
  3. Semicolon is often used to delimit one bit of C++ source code, indicating it’s intentionally separated from the respective code.
  4. Usage of Semicolon in C++ is after class and structure definitions, variable declarations, function declarations, after each statement generally. 
Posted on by