If you had read my previous articles on Hello, world! C program and Basic Structure of C program then you may observed many new terms that may be unknown to you. In this article I will try to explain different terminologies of C programming language based on C Tokens.
C Tokens
Tokens in C programming language are the basic building blocks of the C programs. Like Human Beings are made up of Cells similarly C programs are made up of C Tokens. A C token is either keywords, strings, constants, identifiers, operators or a Special symbols. For Example in the following statement:
int value = 10;
The tokens are int
, value
, =
, 10
and ;
.
There are six different types of C Tokens:
- Constants
- Identifires
- Keywords
- Strings
- Special Symbols
- Operators
1. Constants
Constants are those values which remains unchanged or unaltered throughout the program. These are also called as literals. There are different types of constant like Integer constants, Real or Floating point constants, Character constants and String constants or literals.
Example:
const int number = 10;
For more about Constants read my article on Constants in C.
2. Identifiers
Identifiers in C programming are the case-sensitive names given to the variables, functions, array, etc to identify them.
Example:
float length = 2.3;
In above example length
is the identifier given to the variable.
For more about Identifiers read my article on Identifiers in C
3. Keywords
The keywords in C programming are the reserved words. Since they are reserved words they cannot be used as identifiers. Every keywords has its own special meaning and special function to the C Compiler. Below are the reserved keywords in C programming.
int void else switch return
float main const case
double extern do union
char auto while struct
long resister for enum
short static goto typedef
signed volatile break sizeof
unsigned if continue default
4. Strings
Strings are the array of characters terminated by a null character \0
. Strings are always enclosed inside the double quotes whereas characters are enclosed inside single quotes.
Example:
char web[] = "OjhaBikash";
For more about Strings read my article on C Strings
5. Special Symbols
C language contains some special symbols that have their own meaning and function. And these symbols cannot be used for any other purpose. Some examples of Special Symbols are:
- Asterick
*
:This symbol is used to create the pointer variable.
- Pre processer
#
:This symbol is used as a prefix in pre processer directive command. A pre processer is a program that processes the C source code before the compilation.
- Semicolon
;
:This symbol is used on the end of the statements to indicate the end of the statement.
- Parentheses
()
:They are used in functions to indicate the function call and function parameters.
- Braces
{}
:Braces are used to indicate the start and the end of the block of codes.
- Brackets
[]
:They are used to indicate the single and multi-dimentional arrays subscripts.
- Comma
,
:It is used to seperate more than one statements.
6. Operators
Operaters are the symbols that defines the operation between the operands. Operators helps us to perform specific mathematical and logical operations on the operands. Examples: +
, -
, *
, =
, >
, etc.
For more about Operators read my article on Operators in C