Keywords and Identifiers in C programming

Identifiers are made up of letters and digits, and are case-sensitive. They are variable names, function name and so on. Keywords are the reserved words in C programming. Exactly same variable cannot defined by the user that are keywords.

Keywords

Keywords are predefined, reserved words used in programming. They have their own meaning in C programming and their uses are predefined.  The C language has 32 keywords which are reserved and may not be used as identifiers

Example

int number;

In above example int  is the keyword  that define variable number  as Integer. 


Use lowercase for variable names and uppercase for symbolic constants.

Keywords in C

autodoubleintstruct
breakelselongswitch
caseenumregister typedef
charexternreturnunion
continueforsignedvoid
doifstatic while
defaultgotosizeofvolatile
constfloatshortunsigned

Identifiers

An identifier is a string of alphanumeric characters that begins with an alphabetic character or an underscore character. These are used to represent elements such as variables, functions, arrays and so on.

int number;
float amount;

In above example, number and amount are identifiers. Ass previously mentioned identifier must be different than the keywords. That means, float is keyword hence I cannot write

float float;

Because float is a reserved keyword.

Rules for writing identifiers

  •  Identifiers may only include the following characters: letters (‘a’..’z’, ‘A’..’Z’), digits (‘0’..’9′) and underscores (‘_’). C is case sensitive, so seasideSeaSide and SEASIDE are distinct identifiers.
  • The first character must not be a digit.
  • The identifier must not be one of C’s 32 keywords.

Difference between keyword and identifier

KeywordIdentifier
It is predefined-word in C programmingIt is user-defined word in C programming
These must be written in lowercase only These can be written in lowercase and uppercase
has meaning to compilermust be meaningful to program and programmer