Identifier and keyword in C

Identifiers are the names given to various program elements like functions ,variables , arrays ,structures etc .


Most of the time identifiers consist of letters and digits giving some meaning about that identifier. These letters and numbers can be combined in any order  except that the first character must be a letter .


Both upper and lowercase letters are allowed but most of the time lower case are preferred . These identifiers are case sensitive , upper and lowercase letters are not interchangeable like variable num and NUM are not same , for compiler these are two different variables in C.


Along with letters and numbers , under score is also permitted while naming an identifier and identifier may also begin with underscore but it is rarely done in Real world or you can say it is not done at all

Following are some valid identifiers 

  

x a51 sum_1
interest_rate _gpa(rarely done) AREA



Note : we should always use less characters while naming an identifier but it should be enough to give a meaning so that it will be easier for future maintenance and debugging.


keywords

There are certain reserved words that have predefined meaning in C are called as keywords .
These words are used for intended purpose only and you cannot use these words as an identifier.

All keywords are lowercase so you may think of using Uppercase for identifier but it is not recomended and is consider as bad practice.

Like we have keyword "for" so never use FOR  as identifier even though it is allowed.
A list of keywords are given below.


auto extern sizeof
break float static
case for struct
char goto switch
const if typedef
continue int union
default long unsigned
register void double
return volatile else
short while enum

What is difference between keyword and identifier ?

As i already said Keywords are predefined words with  particular meaning for compiler , but Identifier is  name of  program element like variables , arrays , functions, structures etc

Also Keywords are made by developer of programming language but Identifier are made by programmer who use that language.

Example :  "for" is keyword but "name" is identifier 

Contact Form

Name

Email *

Message *