keywords and identifiers in c programming
The smallest unit in a C programming language is called a token. They are involved in the process of compilation, where a program is converted into the smallest units continuing to the stages of compilation. These smallest units converted are known as tokens. There are six different types of tokens:
- Special Characters
Keywords are reserved words that are assigned with a special meaning in the language. These meanings cannot be changed and hence they cannot be used as variable names if used it will result in an error at the time of compilation. They always specify the type or kind of entity. There are a total of 32 keywords in the C language.
List of keywords:
These were the list of keywords available in C, they must all be written in lowercase.
In C language identifiers are the names assigned to the elements in the programs such as the variables, functions, constants, user-defined data types etc. As the name specifies, identifiers are used to identify the precise elements of the program. The name of the identifiers should be unique, following the rules below.
- Should only contain alphanumeric characters (a-z, A-Z, 0-9) and underscore (_).
- The first character of an identifier should start with an alphabet (A-Z, a-z) or underscore (_).
- They are case sensitive.
- Keywords cannot be used to name identifiers.
- There should be no whitespace between characters while naming identifiers.
- Use of special characters are prohibited.
Difference between keywords and identifiers:
|Keywords are predefined words.||Identifiers are values used to define program elements.|
|It always starts with a lowercase character.||It can start with lowercase, uppercase or underscore.|
|Specify type or kind of entity.||Identifies name.|
|Example: char, if, while, for, etc.||Example: demo, test1, name_iq, etc.|
A program is a set of instructions that consists of several characters and symbols. These various characters and symbols are present in the character set. Hence, the character set comprises of:
All numbers starting from 0-9
Uppercase letters A-Z
Lowercase letters a-z
Comma(,) and Semi-colon(;)
Please write comments or WhatsApp if you find anything incorrect, or you want to share more information about the topic discussed above.