There are specific predefined terms and meanings that a compiler can understand. These terms are also known as Keywords in C language. At the same time, identifiers give unique names to variables, arrays, lists, etc. Also, identifiers are used to distinguish between two variables’ names. Knowing these two terms is very important for programming.
In this blog, we will learn about the two basic terms in C programming, i.e., keywords and identifiers. We will also know the rules and guidelines we need to follow while using keywords and identifiers in our program. Read the complete article to get a good understanding of these terms used in programming.
What are Keywords in C Language
Keywords are the basic building blocks of our program. They are reserved words that have predefined meanings and functions. We cannot use these keywords as identifiers in C programming. In the C program, every keyword has a special meaning.
Keywords in C Language |
int num = 10;
if(num>10){ printf(“ Given number is greater than 10”); } |
For example, if keywords in C language are used to declare a conditional statement, the statement under the if statement will only execute when the if condition holds. Hence, when the number holds a value greater than 10, the compiler will print “Given number is greater than 10”.
In C programming language, many keywords are used, such as int, float, char, double, long, etc. All these keywords tell us the data type of the variable stored. Given here is a list of some popular keywords used in C programming.
Keywords in C Language | ||||
auto | break | case | char | const |
continue | default | do | double | else |
enum | extern | float | for | goto |
if | int | long | register | return |
short | signed | sizeof | static | struct |
switch | typedef | union | unsigned | void |
volatile | while | _Bool | _Complex | _Imaginary |
inline | restrict |
What Are Identifiers in C Language?
Identifiers are the names we choose for a function, variable, list, array, or other user-defined item. They are used to uniquely identify these elements in the code. Once we assign a name to any entity, we cannot use the same name for any other entity. Some rules must be followed in the C program while naming an entity.
Rules for Naming Identifiers
- After assigning a name to a variable, function, array, or any other entity, you cannot assign the same name to other entities in the same scope.
- In the C program, every identifier must start with an uppercase or lowercase letter. You can also use an underscore (‘_’) at the beginning.
- Identifiers in the C program are treated differently. “PhysicsWallah” and “physicsWallah” are two different identifiers.
- Also, you cannot use keywords as an identifier in the C program.
- Special characters like @, $, %, etc., are not allowed while naming the identifiers.
- You cannot use blank spaces or commas while naming an identifier.
- The maximum length of an identifier can go up to 31 characters long.
Also Read Technical Topics
Difference Between Keywords and Identifiers In C Language
Keywords and identifiers are the basic building blocks of programming languages. The table given below contains the significant differences between keywords and identifiers in C.
Difference Between Keywords and Identifiers in C language | |
Keywords are the predefined words in a programming language. | Identifiers are the names given to variables, functions, lists, etc. |
Keywords in C language cannot be used as identifiers. | Identifiers are user-defined variables that give a unique name to different entities in programming. |
The keywords always start with a lowercase letter. | Identifiers can start with either lowercase or uppercase letters. |
It only contains alphabetical characters. | It contains only numerals, letters and underscores. No special symbols are allowed. |
It specifies the data type of an entity. | It gives the name of an entity. |
You can use keywords as many times as you want. | You cannot use the same identifiers name in the same scope. |
Example: int, float, double, if, else, default, etc. | Example: int num, where num is an identifier. |
FAQs
What are keywords in C language?
Keywords in C language are predefined words in any language. No keywords can be used as an identifier.
What are identifiers in a programming language?
Identifiers are the unique names given to any particular entity in a programming language. They are used to identify any entity in a program uniquely.
Are special symbols allowed in identifiers?
No special symbols or punctuation marks are allowed while naming an identifier in C.
Can we use the same identifiers for naming two entities in C language?
No, identifiers are used to identify any entity in the program uniquely. We cannot use the same identifiers within the same scope in C language.