You are on page 1of 2

Identifiers and Keywords in C

Identifiers are names that are given to various program elements, such as variables, functions and
arrays.

# An Identifier can only have alphanumeric characters( a-z , A-Z , 0-9 ) and underscore( _ ).

# The first character of an identifier can only contain alphabet( a-z , A-Z ) or underscore ( _ ).

# Identifiers are also case sensitive in C. For example name and Name are two different identifier in
C.

1.#include <stdio.h>
2.int main()
3.{
4.int qty = 45;
5.float price = 12.75;
6.char item_Code = 'A';
7.char C_name[20] = "Naomi";
8.printf("%s take %d %c item which price is $%0.2f per item\n",C_name,qty,item_C
9.ode,price);
10.return 0;
11.}

These are the identifiers in above program:

1.int qty = 45 : Here qty is a identifier which denotes a variable of type integer which is initialised
with value 45.
2.float price = 12.75 : Here price is a identifier which denotes a variable of type float which is
initialised with value 12.75.
3.char item_Code = 'A' : Here item_Code is a identifier which denotes a variable of type Character
which is initialised with cha A.
4.char C_name[20] = "Naomi" : Here C_name is a identifier which denotes a variable of type
Character Array which is initialised with chars Naomi.

Rules for writing identifier

1.An identifier can be composed of letters (both uppercase and lowercase letters), digits and
underscore '_' only.

2.The first letter of identifier should be either a letter or an underscore. But, it is discouraged to start
an identifier name with an underscore though it is legal. It is because, identifier that starts with
underscore can conflict with system names. In such cases, compiler will complain about it. Some
system names that start with underscore are _fileno, _iob, _wfopen etc.

1
3.There is no rule for the length of an identifier. However, the first 31 characters of an identifier are
discriminated by the compiler. So, the first 31 letters of two identifiers in a program should be
different.

Keywords
– predefined meanings in C. can be used only for their intended purposes.
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

You might also like