Home C Language C Basic Syntax

C Basic Syntax

To write a c program you must have a basic knowledge of C syntaxes. You have seen a basic structure of C program, so it will be easy to understand other basic building blocks of the C programming language. The following concepts will get some awareness about C basic syntaxes.

Tokens in C

A token is smallest individual unit. C language supports the following tokens.

  1. character set.
  2. constants.
  3. keywords.
  4. variables.
  5. datatypes.
  6. operators.

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. For example, following are two different statements:

printf(“Hello, World! \n”);



Comment lines start with /* and terminates with */. Any number of lines included in the block of /*…..*/ are marked as comments and these lines are ignored (not translated into machine language) by the compiler while compiling the program. Comments can be present anywhere in the program and they are meant for documentation purpose alone.

We can also use “//” for comments which can able to hold only one of content.


/* here the sample c program

to show you to how a program will execute*/

int a; //to store a integer value.


Variables, functions, labels and various other user-defined items are called identifiers. The length of these identifiers can vary from one to several characters. The first character must be a letter or an underscore and the subsequent characters must be letters, digits and underscores.

Some correct and incorrect identifier names are given bellow:

Incorrect Identifier Correct Identifier
s-name s_name
Qty&marks Qty_marks
26Batch Batch26
avg.marks avgMarks

Except underscore (_) any other symbol should not permitted in identifier names.

C is a case sensitive programming language. Thus marks, Marks and MARKS are three different identifiers in C.

An identifier cannot be the same as a C keyword and should not have the same name as the built-in C library functions. For example, we cannot declare char, scanf and clrscr() as identifiers because they are reserved words in C library.


Keywords are also called reserved words. These words are used to build the block of program statements. When writing a keyword in program it must be lower case. It has fixed meaning, that meaning cannot be changed. Although we can use them for preprocessor macro names. Only the exact spelling of keywords is reserved. For example union is reserved but Union and UNION are not.

C language supports 32 keywords. The keywords are as follows:

auto, break, case, char, const, continue, default, do, double, else, enum, extern, float, for, goto, if, int, long, register, return, short, signed, sizeof, static, struct, switch, typedef, union, unsigned, void, volatile, while.

 Whitespace in C

A line containing only whitespace, possibly with a comment, is known as a blank line, and a C compiler totally ignores it. Whitespace is the term used in C to describe blanks, tabs, newline characters and comments. Whitespace separates one part of a statement from another and enables the compiler to identify where one element in a statement, such as int, ends and the next element begins. Therefore, in the following statement:

int marks;

There must be at least one whitespace character (usually a space) between int and age for the compiler to be able to distinguish them. On the other hand, in the following statement:

juice = fruit + milk; // get the juice

No whitespace characters are necessary between ‘juice’ and ‘=’, or between ‘=’ and fruit, although you are free to include some if you wish for readability purpose.