Difference Between Keyword And Identifier In C

SHARE

What is Identifier?

An identifier is a collection of alphanumeric characters that begins either with an alphabetical character or an underscore, which are used to represent various programming elements such as variables, functions, arrays, structures, unions, labels, etc.

An identifier can be composed of letters such as uppercase, lowercase letters, underscore, digits, but the starting letter should be either an alphabet or an underscore. If the identifier is not used in the external linkage, then it is called as an internal identifier. If the identifier is used in the external linkage, then it is called as an external identifier.

There are 52 alphabetical characters (uppercase and lowercase), underscore character, and ten numerical digits (0-9) that represent the identifiers. There is a total of 63 alphanumerical characters that represent the identifiers.

Rules for constructing Identifiers

  • The first character of an identifier should be either an alphabet or an underscore, and then it can be followed by any of the character, digit, or underscore.
  • It should not begin with any numerical digit.oIn identifiers, both uppercase and lowercase letters are distinct. Therefore, we can say that identifiers are case sensitive.
  • Commas or blank spaces cannot be specified within an identifier.
  • Keywords cannot be represented as an identifier.
  • The length of the identifiers should not be more than 31 characters.
  • Identifiers should be written in such a way that it is meaningful, short, and easy to read.

What is Keyword?

Keywords are known as predefined as well as reserved words that are used in programming holding special meanings to the compiler. Keywords help in defining any statement in the program. They are part of the syntax and also we cannot use them as an identifier. Since C is a case sensitive language, all of the keywords must be written in lowercase format.

In other words, a keyword is a reserved word. You cannot use it as a variable name, constant name etc. There are only 32 reserved words (keywords) in C language. No header file is needed to include the keywords.

Rules for constructing Keyword

  • Keywords are the words whose meaning has already been explained to the C compiler and their meanings cannot be changed.
  • Keywords can be used only for their intended purpose.
  • Keywords cannot be used as user-defined variables.
  • All keywords must be written in lowercase.

Identifier vs Keyword

IDENTIFIERKEYWORD
Identifiers are the values used to define different programming items such as variables, integers, structures, unions and others and mostly have an alphabetic character.Keywords are the predefined and specific reserved words, which hold special meaning. Keywords help in defining any statement in the program. 
An identifier can be in upper case or lower case.A keyword should be in lower case.
They help to locate the name of the entity that gets defined along with a keyword.They help to identify a specific property that exists within a computer language.
An identifier can consist of alphabetical characters, digits and underscores.A keyword contains only alphabetical characters.
When you declare any identifier you can only use underscore but not any other symbol.Keywords defined in C++ library does not contain any symbol. 
First character can be a uppercase, lowercase letter or underscore.A keyword always starts with a lower case. 
Examples of identifiers are: Test, count1, high_speed, etc.Examples of keywords are: int, char, if, while, do, class etc.

What you need to know about Keyword

  • Keywords are the predefined and specific reserved words, which hold special meaning. Keywords help in defining any statement in the program. 
  • A keyword should be in lower case.
  • They help to identify a specific property that exists within a computer language.
  • A keyword contains only alphabetical characters.
  • Keywords defined in C++ library does not contain any symbol. 
  • A keyword always starts with a lower case. 
  • Examples of keywords are: int, char, if, while, do, class etc.

What you need to know about Identifier

  • Identifiers are the values used to define different programming items such as variables, integers, structures, unions and others and mostly have an alphabetic character.
  • An identifier can be in upper case or lower case.
  • They help to locate the name of the entity that gets defined along with a keyword.
  • An identifier can consist of alphabetical characters, digits and underscores.
  • When you declare any identifier you can only use underscore but not any other symbol.
  • First character can be a uppercase, lowercase letter or underscore.
  • Examples of identifiers are: Test, count1, high_speed, etc.