Keywords & Identifiers
In this tutorial, you will learn about keywords and identifiers. Keywords which are reserved words in the C programming language and essential parts of its syntax. Additionally, you will learn about identifiers and the process of naming them. Keywords and identifiers are both integral for defining syntax, semantics, and precise communication in C programming.
Keywords in C programming represent reserved words with predefined meanings. These words cannot be utilized as identifiers, such as variable names or function names.
These keywords are part of the language’s syntax and serve specific purposes in the code. Some examples of keywords in C programming include “if,” “else,” “for,” “while,” “int,” “float,” “return,” and “switch.” These keywords are crucial for defining control structures, data types, and other fundamental aspects of C programming.
Money is a variable of type int, as indicated by the keyword “int” in this sentence (integer).
In C programming, it is important to type all keywords in lowercase because C is a case-sensitive language.
In C programming, Identifier refers to name given to various program elements such as variables, functions, arrays etc. These names enable the identification and referencing of these program elements within the code.
It is good practice to choose meaningful and descriptive names for identifiers, making the code more readable and understandable.
int school; double students;
Here, we can identify “school” and “students” as identifiers.
Also, keep in mind that identifier names and keywords must be distinct. Since int is a keyword, you cannot use int as an identifier.
Rules for naming identifiers
They can consist of letters (both uppercase and lowercase), digits, and underscores.
- The first character of an identifier must be a letter or an underscore.
They should not be a keyword or a reserved word in C.
Identifiers in C programming treat uppercase and lowercase letters as distinct, which means they are case-sensitive.
Identifiers must be distinct, as they serve the purpose of providing a unique name to an entity that facilitates its identification during the execution of an application.