C Token
C Token and Keyword
The C tokens are the basic buildings blocks in C language which are constructed together to write a C program. Each and every smallest individual unit in the C program is known as C Tokens.There are six types of tokens in the C language that are given below:
- Keywords
- Identifier
- Constant
- String
- Operator
- Punctuation
Lets us consider an example of Token.
Keywords in C
The keyword is used to perform an internal operation. We cannot use it as the variable name, constant name, etc.
Every keyword exists in lower case latter like auto, break, case, etc.
There are 32 keywords in C language.
auto | double | int | struct |
break | else | long | switch |
case | enum | register | typedef |
char | extern | return | union |
const | float | short | unsigned |
continue | for | signed | void |
default | goto | sizeof | volatile |
do | if | static | while |
Identifiers in C
The identifier is a name used to identify variables, constants, functions, and user-defined data. There are following some rules for naming identifier.
- It can only alphanumeric characters (a-z, A-Z, 0-9) and underscore ( _) symbol.
- Identifier names must be unique.
- The first character names must be unique.
- We cannot use a keyword as identifiers.
- Only first thirty-one (31) characters are significant.
- Must not contain white spaces.
- Identifiers are case-sensitive.
int amount; double totalbalance;In the given above example amount and total balance are identifiers and double is a keyword.
Constant in C
Constant is a variable that value never changes during execution once defined. It is also known as literals. Const keyword is used to define a constant.
Syntax:
const type constant_name;Example:
constint ID =10; 12-11-17Strings in C
String constants are the sequence of characters enclosed within double quotes.
Every string constant is automatically terminated with a special character called the null character which represents the end of the string.