C Language Syntax Rules


In C programming language there are some rules for writing programs. And there are some rules that are specified by C to write sequence of characters. In C programming language the smallest unit is called token. A token can be an identifier, keyword, constant, or a variable. We can also refer a C program as a collection of tokens.

The C language syntax rules are used to specify that how the sequence of characters will be grouped together to form token. The following are some of the tokens in C programming language: int, delimiters, comments, semi colon etc.


Comments:

Comments are the lines of program that are not executed. The compiler ignores comments and does not include them in the executable program. That is why the comments do not affect the size of executable program.

Comments are used to increase the readability of the program. Comments are notes about different lines of code that explain the purpose of code. The user can insert information notes in the code. It helps in debugging and modifying the program later.

Comments can be added anywhere in the program or code.

Comments are of two types:


Single line comments:

Comments on single line are added by using double slash “//”. Anything written on the right side of the double slash is considered as comments and is ignored during execution.


Multi line comments:

Multi line comments are inserted to the code by placing /* at the beginning of the comments. The character */ is used to end the multi line comments.

EXAMPLES:

Following line is an example of single line comment:

//practice makes a man a good programmer.

Another way to add comments on a single line is as follows:

/* these are also comments…*/

In order to add comments on multiple lines in program, following way is used:

/*these lines are

For the purpose of

Writing comments*/


Some basic Syntax rules for C program:

The following are some basic rules for C program:

  1. All the instruction and name of the functions etc should be written in lowercase because C is a case sensitive language.
  2. The C statements must be ended with a semi colon.
  3. In C programming language we use whitespace for blanks and tabs.
  4. The white spaces are required in between keywords and identifiers.


Basic structure of C program:

Consider the following labeled figure of a C program:

Basic structure of C program