C Keywords and Identifiers

In this tutorial, you will learn about keywords in c language also known as reserved words in C programming and identifiers which are used for naming.

C Keywords

Keywords are reserved words having a special meaning in the programming language. Keywords are pre-defined words in a programming language that convey a special meaning to the compiler. 

Reserved words(C Keywords) for special purposes so we cannot be used as variable names or as normal identifier names and it is wrong because by used keywords as variable names we are trying to assign a new meaning to the keyword whose pre-defined words in the language which is not allowed.
  • Keywords are reserved words that are predefined in a programming language.
  • We can not use keywords as variable names.
  • You cannot redefine keywords.

The language supports 32 C keywords which are given below

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


C Identifiers

Identifier is a fundamental building block and is used as the general terminology for names given to different parts of programs are variables, arrays, and functions. 

Identifiers are user-defined names consisting of an arbitrarily long sequence of digits and letters. The first character must be a letter (A-Z or a-z) or Underscore(_) and underscore is count as a letter. 

We cannot use C keywords as C identifiers. These differ in spelling and if once we declared identifier it can be used in whole later program refer to the linked value.

Rules for naming Identifiers

  • The first character must be Letter(A-Z or a-z) or Underscore(_).
  • You can not use any special symbol in identifier i.e. @,+,-,., etc.
  • You can not use keywords as identifiers.
  • It should not contain any space between them.
  • In the same program, two or more same identifiers are not possible.

Some examples of c identifiers


_file          Valid
MYDOB      Valid
MY.DOB     invalid because it contains a special symbol dot(.)
96file        invalid because the first character is a digit.
int            invalid because it is the keyword.

For more C Tokens

Share this

0 Comment to "C Keywords and Identifiers"

Post a Comment