• Networking
  • Programming
  • DBMS
  • Operating System
  • Internet
  • Hardware
  • Software

Tech Differences

Know the Technical Differences

Difference Between Keyword and Identifier

keyword and identifierEvery language has keywords and identifiers, which are only understood by its compiler. Keywords are predefined reserved words, which possess special meaning. Each keyword defines the “type” declared data. Keywords should not be used as identifiers. An identifier is a unique name given to a particular variable, function or label of class in the program. To create a variable, both a keyword and an identifier are bind together.

The identifiers can be altered if required, while this is not the case with keywords, which are fixed, we can not change it according to our need. This content further elaborates the difference between a keyword and an identifier.

Content: Keyword Vs Identifier

  1. Comparison Chart
  2. Definition
  3. Key Differences
  4. Conclusion

Comparison chart

Basis for ComparisonKeywordIdentifier
BasicKeywords are the reserved words of a language.Identifiers are the user defined names of variable, function and labels.
UseSpecify the type/kind of entity.Identify the name of a particular entity.
FormatConsider only letters.Consider letters, underscore, digits.
CaseUse only lowercase.Lower and upper cases, both are allowed.
SymbolNo special symbol, punctuation is used.No punctuation or special symbol except 'underscore' is used.
ClassificationKeywords are not further classified.Identifier are classified into 'external name' and 'internal name'.
Starting letterIt always starts with a lowercase letter.First character can be a uppercase, lowercase letter or underscore.
Exampleint, char, if, while, do, class etc.Test, count1, high_speed, etc.

Definition of Keywords

The words which are reserved by C++ are called “keywords”. These keywords can not be used to name an identifier and to name other entity of the program. Each keyword has a distinct meaning and is used by a compiler to perform a specific action. For example, ‘int’ is used to create an identifier of integer type, ‘float’ is used to create an identifier of float type.

Example

To get a clear image of keywords, let’s overview a real-life example. We have a ‘book’ named ‘Complete Reference’. Here the word ‘Book’ is the keyword, and the name “complete_reference” is an identifier to the keyword ‘Book’. Now, Keyword specifies, what is a “complete_reference”, the answer is, it is a “Book”.

Now, let’s take an example of a program if we write ‘float salary’. Here, ‘keyword’ is ‘float’ and ‘salary’ is an ‘identifier’. Now, if you ask what do you mean by ‘salary’, the answer is, it specifies that it is a ‘variable’ which is ‘float’ in nature and accepts ‘float values’.

Definition of Identifier

The name you provide to an entity in a program so that it can be uniquely identified is called “identifier”. The names of variables, functions, labels of a class and various other user-defined entities are ‘identifiers’. The identifier can never be used as a ‘keyword’.

Example

To understand it in a better way, let’s elaborate the above example of ‘keyword’. As “Book” is a ‘keyword’ and “Complete_reference” is an identifier. Now, if we want a ‘Book of Complete Reference’. When we ask to the shopkeeper, that we want a “Book” he/She will not identify which ‘Book’, unless we specify the books name, i.e. “complete_reference”.

Now, take the above example of a program, we know ‘float’ is a ‘keyword’, and ‘salary’ is an ‘identifier’. Now, if you want to print the value of variable ‘salary’, you have to explicitly call the variable’s name to print the ‘salary’, here, calling ‘float’ won’t work. So identifier is a name by which we can call our created entity in a program.

Rules for constructing an identifier

  • The first character of an identifier should mandatorily be a letter. (‘_’ Underscore can also be used as the first letter)
  • It can be a set of letters, digits and underscore.
  • Uppercase and lowercase letters are treated differently.
  • All of the characters are significant.
  • The use of reserved words as the name of identifiers or variables are forbidden.
  • White spaces are not allowed.
  • An identifier can contain 1024 characters at maximum, as ANSI standard requires that the C++ compilers must provide at least this number of characters.

Key Differences Between Keyword and Identifier

  1. Keywords are used to recognize the type/kind of entity while an identifier is used to name that entity uniquely. For example, if we write ‘int number’, where ‘int’ is a keyword, and ‘number’ is an identifier, i.e., this statement clearly defines that we define an entity ‘number’ which is of type int(integer).
  2. Keywords are distinct; they are not further classified. On the contrary, if identifiers are involved in an external link process, i.e. if it include function names and global variable that are shared between files, then it is called ‘external names’, while they are not used in external link process and include the name of local variable, then it is called ‘internal names’.
  3. The identifier can never be same as keywords, and the name of functions that are in C++ library.
  4. Keywords defined in C++ library does not contain any symbol. Conversely, when you declare any identifier you can only use underscore but not any other symbol.
  5. A keyword always starts with a lower case. As against, an identifier can either start with an upper case or a lower case

Conclusion

Keywords and identifiers are the building blocks of the program. They are specifically used by a compiler to uniquely define the type/kind and a name of a particular variable or a function of a class.

Related Differences:

  1. Difference Between Identifier and Variable
  2. Difference Between Float and Double
  3. Difference Between Strong and Weak Entity
  4. Difference Between throw and throws in Java
  5. Difference Between Type Casting and Type Conversion

Comments

  1. Best SMS Company says

    September 8, 2017 at 7:08 am

    Hey, thank you for providing us such a good explanation to us.

    Reply
  2. Dhruv says

    April 2, 2019 at 4:53 pm

    Good information

    Reply
  3. Jyoti says

    August 31, 2019 at 3:34 pm

    Informative content……

    Reply
  4. Payal londhe says

    March 6, 2021 at 5:42 am

    What difference between variable, identifier and keywords?

    Reply
  5. Bisman kaur says

    March 14, 2021 at 11:59 am

    Thanks a lot for this information. It helped me a lot.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Top 10 Differences

  • Difference Between OLTP and OLAP
  • Difference Between while and do-while Loop
  • Difference Between Guided and Unguided Media
  • Difference Between Preemptive and Non-Preemptive Scheduling in OS
  • Difference Between LAN, MAN and WAN
  • Difference Between if-else and switch
  • Difference Between dispose() and finalize() in C#
  • Difference Between for and while loop
  • Difference Between View and Materialized View
  • Difference Between Server-side Scripting and Client-side Scripting

Recent Addition

  • Difference Between Java and Python
  • Difference Between PHP and HTML
  • Difference Between GPS and GNSS 
  • Difference Between Virtualization and Containerization
  • Difference Between Storage and Memory

Categories

  • Artificial Intelligence
  • DBMS
  • Hardware
  • Internet
  • Networking
  • Operating System
  • Programming
  • Software

Copyright © 2025 · Tech Differences · Contact Us · About Us · Privacy