C Programming Keywords and Identifiers

C programming keywords and identifiers; In this tutorial, i am going to show you keywords or reserved keywords and identifiers in C programming.

C Programming Keywords and Identifiers

Let’s see the c programming keywords and identifiers; is as follows:

  • C Keywords
  • C Identifiers

C Keywords

Reserved words (also called keywords) are defined with predefined meaning and syntax in the language. These keywords have to be used to develop programming instructions. Reserved words can’t be used as identifiers for other programming elements like the name of variable, function, etc.

The following example of reserved keyword in c.

int my_data;

Here, int is a keyword that indicates my_data is a variable of type int (integer).

As C is a case-sensitive language, all keywords must be written in lowercase. Here is a list of all keywords allowed in ANSI C.

autodoubleintstruct
breakelselongswitch
caseenumregistertypedef
charexternreturnunion
continueforsignedvoid
doifstaticwhile
defaultgotosizeofvolatile
constfloatshortunsigned

C Identifiers

C identifier is a name used to identify a variable, function, class, module, or other objects. An identifier starts with a letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores and digits (0 to 9).

Identifiers must be unique. They are created to give a unique name to an entity to identify it during the execution of the program. For example:

int loan;
double remain_loan;

Here, loan and remain_loan are identifiers.

Also remember, identifier names must be different from keywords. You cannot use int as an identifier because int is a keyword.

Rules for naming identifiers

  1. A valid identifier can have letters (both uppercase and lowercase letters), digits and underscores.
  2. The first letter of an identifier should be either a letter or an underscore.
  3. You cannot use keywords like intwhile etc. as identifiers.
  4. There is no rule on how long an identifier can be. However, you may run into problems in some compilers if the identifier is longer than 31 characters.

Note that:- You can choose any name as an identifier if you follow the above rule, however, give meaningful names to identifiers that make sense. 

More C Programming Tutorials

Be First to Comment

Leave a Reply

Your email address will not be published.