C Tokens, Keywords, Identifiers
What is a Character set?
Like every other language, 'C' also has its own character set. A program is a set of instructions that, when executed, generate an output. The data that is processed by a program consists of various characters and symbols. The output generated is also a combination of characters and symbols.
A character set in 'C' is divided into,
- Letters
- Numbers
- Special characters
- White spaces (blank spaces)
A compiler always ignores the use of characters, but it is widely used for formatting the data. Following is the character set in 'C' programming:
- Letters
- Uppercase characters (A-Z)
- Lowercase characters (a-z)
- Numbers
- All the digits from 0 to 9
- White spaces
- Blank space
- New line
- Carriage return
- Horizontal tab
- Special characters
- Special characters in 'C' are shown in the given table,
What is Token in C?
TOKEN is the smallest unit in a 'C' program. It is each and every word and punctuation that you come across in your C program. The compiler breaks a program into the smallest possible units (tokens) and proceeds to the various stages of the compilation. A token is divided into six different types, viz, Keywords, Operators, Strings, Constants, Special Characters, and Identifiers.
Keywords and Identifiers
In 'C' every word can be either a keyword or an identifier.
Keywords have fixed meanings, and the meaning cannot be changed. They act as a building block of a 'C' program. There are a total of 32 keywords in 'C'. Keywords are written in lowercase letters.
Following table represents the keywords in 'C'-
An identifier is nothing but a name assigned to an element in a program. Example, name of a variable, function, etc. Identifiers are the user-defined names consisting of 'C' standard character set. As the name says, identifiers are used to identify a particular element in a program. Each identifier must have a unique name. Following rules must be followed for identifiers:
- The first character must always be an alphabet or an underscore.
- It should be formed using only letters, numbers, or underscore.
- A keyword cannot be used as an identifier.
- It should not contain any whitespace character.
- The name must be meaningful.
Summary
- A token is the smallest unit in a program.
- A keyword is reserved words by language.
- There are total of 32 keywords.
- An identifier is used to identify elements of a program.
0 Comments