C Basic Syntax


C language syntax specify rules for sequence of characters to be written in C language. The rule specify how character sequence will be grouped together to form tokens. A smallest individual unit in c program is known as C Tokens. Tokens are either keyword, identifier, constant, variable or any symbol which has some meaning in C language. A C program can also be called as collection of various tokens.


Tokens in C

A C program consists of various tokens and a token is either a keyword, an identifier, a constant, a string literal, or a symbol. For example, the following C statement consists of five tokens:

printf("Hello, World! \n");
The individual tokens are:
printf
(
"Hello, World! \n"
)
;

Semicolons ;

In C program, the semicolon is a statement terminator. That is, each individual statement must be ended with a semicolon. It indicates the end of one logical entity.

printf("Hello, World! \n");
return 0;

Comments

Comments are simple text in your C program that increases readability of programs. Compiler ignore anything written as comment in your program.

//This is a comment      Single line Comment

/*This is a comment*/    Single line Comment

/*This is a long 
and valid comment*/      Multi line Comment

//this is not
  a valid comment        Wrong Syntax

Identifiers

A C identifier is a name used to identify a variable, function, or any other user-defined item. An identifier starts with a letter A to Z or a to z or an underscore _ followed by zero or more letters, underscores, and digits (0 to 9).

C does not allow punctuation characters such as @, $, and % within identifiers. C is a case sensitive programming language. Thus, Manpower and manpower are two different identifiers in C. Here are some examples of acceptable identifiers:

lpu abc  show_name  bhai_1223

sachin30   _start  d kke222 HaryaNa

Share this article on