After reading this character set topic, you will understand C Tokens, C Keywords and you will know the C Identifiers and Rule for defining identifiers.
Like any other programming language, C language has its own character set is used to form words, statements, and expression which makes programming easier.
C character set includes the following : –
lowercase letters :- a - z uppercase letters :- A - Z digits :- 0 - 9 Special characters :- ~ ' ! @ # % ^ & * () _ - + = | \ {} [] : ; <> , . ? / white space characters :- blank space, horizontal tab, newline, form feed, vertical tab, carriage etc.
C – Tokens
In C program the smallest individual units known to compiler are known as tokens. C tokens are classified as shown below,
Keywords
Keywords are those words having fixed meaning in C language. In C list of all the keywords shown below:
auto do goto signed unsigned break double if sizeof void case else int static volatile char enum long struct while const extern register switch continue float return typedef default for short union
Identifiers
Identifier are the name set to variables, data types, functions and labels. Identifier are the combination of alphabet letters i.e. uppercase (A to Z) and lowercase (a to z), digits (0 to 9), and the special character _ (underscore).
For example:
The statement in C is given by
int sum;
Indicate that
- int represent integer data type.
- sum is identifier.
Rule for defining identifiers:
1. An alphabet or underscore used in the starting letter of identifiers.
For example:
int _sum, sum_amount;
Here sum and sum_amount both are valid identifiers.
2. An identifier cannot be keywords or standard function name.
For example:
int else;
Here int else invalid identifier because else is keyword.
3. An identifier length up to 32 characters allowed.
4. Only underscore in special characters is allowed.
For example:
int sum_amount;
Here sum_amount is valid identifier.
5. Identifiers are case sensitive i.e. uppercase letters and lower case letters are different.
For example:
int sum,Sum;
Here, sum and Sum both are different identifiers.