C Syntax

C syntax : Every programming language has different type of syntax or format that tells how a program to be written in particular language. A syntax is a set of rules, principles and processes that governs the structure of a program. Without any exception, C language also has own syntax or format.

C language syntax specifies a set of rules and principles for sequence of characters to be written in C language. In simple words, it tells how to form statements, where to use single or double quotes, where to use square or curly brackets, how to start the line of code or end, etc in an C program.

C tokens

C tokens : A token is a smallest or basic unit of a program. Meaningful words are created by adding one or more characters in a sequence. These words are called tokens.

In C language, we can divide C tokens like this.

  1. Keywords

      (do, if, else, etc)
  2. Identifiers

      (sum, length, i, etc)
  3. Constants

      (-14, 12, 19.93, etc)
  4. Operators

      (+, -, *, /, etc)
  5. Special Symbols

      ((, ), [, ], {, }, ?, etc)

1 Keywords : Keywords are reserved or predefined words that have special meaning to the C compiler. Keywords have kept reserved for special tasks in C programming. We can not use keywords for variable names, function names, etc. In coming sections, we will learn about the C keywords in detail.

2 Identifiers : An identifier is a name that is used to identify a variable, a function, or any other user defined item.

Rules for identifiers :
  1. An identifier can contain one character or more than one.
  2. No white space is allowed within an identifier.
  3. An identifier can have alphabets, digits and underscore like a_1.
  4. An identifier can not be any reserved word or keyword like int, float, char, etc.
  5. An identifier can start with alphabet and underscore only and first letter of the identifier can not be a digit like 1var, it's wrong.

3 Constants : Constant is such a data item or value that can not be changed or altered during the program execution. In coming sections, we will learn about C constants in detail.

4 Operators : An operator is a symbol or a sign that is used to perform certain operation like + symbol operator that takes two operands and generates output after adding the operands. In coming sections, we will learn about C Operators in detail.

5 Special Symbols : C language have many special symbols which meaning are already defined. Some special symbols of C language are given below with meaning.

; :- this special symbol is used to terminate single statement in C language.

{} :- These opening and closing curly braces marks the start and end of a block of code.

[] :- Opening and closing brackets are mostly used in C array.

& :- this special symbol can be used to access memory address of a variable.

() :- These special symbols are used to indicate function calls and function parameters.

6 Comments : In programming, a comment is a programmer-readable explanation in the source code of a program. Comments are ignored and not executed by compilers.

Type of Comments :
  1. Single Line Comment (//...) :- It is used to comment single line at once time.
  2. Multi Lines Comment (/*...*/) :- It is used to comment multiple lines at once time.

In coming sections, we will learn about C comments in detail.

7 Semicolon (;) : It is used to terminate single statement in C language and every statement must be ended with a semicolon.

C syntax

example by C source code :
* Author : Vktutorial
* Date : 2018-04-14
* Description : Prints "Hello World !!" on the screen.

#include <stdio.h>
#include <conio.h>

int main() {
/* This statement prints "Hello World !!" on the console. */
printf("Hello World !!");

return 0;

Output :

Hello World !!

NOTE : C language is a case-sensitive language. It means that Main and main have different meaning.

Next Topic : Variables in C...