Difference Between Keyword and Identifier

Computer ProgrammingProgrammingMiscellaneous

In this post, we will understand the difference between a keyword and an identifier.

Keyword

  • They define a specific kind of entity.

  • It always starts with a lower case letter.

  • They are pre-defined words that are reserved to work with programs.

  • They can’t be used anywhere else.

  • It can only contain alphabetical characters.

  • It helps identify specific property which exists within a language.

  • There are special symbols or punctuations used.

Example

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

Identifier

  • All of them are not variables.

  • They are used to name a variable, a function, a class, a structure, a union.

  • It is created to give a unique name to an entity.

  • They can consist of alphabets, digits, and underscores.

  • There is no punctuation or special symbol, except the underscore.

  • It can be upper case or lower case.

  • It helps locate the name of the entity which is defined along with a keyword.

Example

enum geeks_artiles_in {Jan=1, Feb, Mar, Apr, May, June, July}
raja
Published on 24-Mar-2021 14:21:55
Advertisements