New Tutorials:   NUMPY    TKINTER    KOTLIN    JAVASCRIPT    SASS/SCSS    PL/SQL    Matplotlib    C++ Programs
See the Tutorial List

C Language Basic Syntax Rules

C language syntax specify rules for sequence of characters to be written in C language. In simple language it states how to form statements in a C language program - How should the line of code start, how it should end, where to use double quotes, where to use curly brackets etc.

The rule specify how the character sequence will be grouped together, to form tokens. A smallest individual unit in C program is known as C Token. Tokens are either keywords, identifiers, constants, variables or any symbol which has some meaning in C language. A C program can also be called as a collection of various tokens.

In the following program,

int main()
    return 0;

if we take any one statement:


Then the tokens in this statement are→ printf, (, "Hello,World", ) and ;.

So C tokens are basically the building blocks of a C program.

Semicolon ;

Semicolon ; is used to mark the end of a statement and beginning of another statement. Absence of semicolon at the end of any statement, will mislead the compiler to think that this statement is not yet finished and it will add the next consecutive statement after it, which may lead to compilation(syntax) error.

int main()
    return 0;

In the above program, we have omitted the semicolon from the printf("...") statement, hence the compiler will think that starting from printf uptill the semicolon after return 0 statement, is a single statement and this will lead to compilation error.


Comments are plain simple text in a C program that are not compiled by the compiler. We write comments for better understanding of the program. Though writing comments is not compulsory, but it is recommended to make your program more descriptive. It make the code more readable.

There are two ways in which we can write comments.

  1. Using // This is used to write a single line comment.
  2. Using /* */: The statements enclosed within /* and */ , are used to write multi-line comments.

Example of comments :

// This is a comment

/* This is a comment */

/* This is a long 
and valid comment */

// this is not
  a valid comment

Some basic syntax rule for C program

  • C is a case sensitive language so all C instructions must be written in lower case letter.
  • All C statement must end with a semicolon.
  • Whitespace is used in C to describe blanks and tabs.
  • Whitespace is required between keywords and identifiers. We will learn about keywords and identifiers in the next tutorial.

C language syntax rules