C Keywords and Identifiers

C Keywords and Identifiers

C keywords and identifiers; Through this tutorial, you will learn about keywords or reserved keywords and identifiers in C programming.

C Keywords and Identifiers

  • 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. 

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *