JavaClassCode.com

facebook twitter googleplus

C Tutorial

C Introduction C Installation C Keywords and Identifier C Variables C Constants C Data Types C Input/Output C Operators C Introduction Examples

C Control Flow

C if...else C for loop C while loop C break and continue C switch case C goto Control Flow Examples

C Functions

C Function C User-define Function C Function Types C Recursion C Storage Class C Function Examples

C Pointers

C Pointers C Pointers & Arrays C Pointers and Functions C Memory Allocation Array and Pointer Examples

C Strings

C Strings C String Functions C String Examples

Structure and Union

C Structure C Struct and Pointers C Struct and Function C Unions C Struct Examples

C Programming Files

C Files Input/Output C Files Examples

Additional Topics

C Enumeration C Preprocessors C Standard Library C Programming Examples

Keywords and Itentifier


Keywords

Keywords are the words whose meaning has already defined to the C compiler (or in a broad sense to the computer). These keywords cannot be used as variable names because if we do so we are trying to assign a new meaning to the keyword, which is not allowed by the C compiler.

The keywords are also called as Reserved words. There are only 32 keywords available in C language. These keywords are mentioned below:

autodoubleintstruct
breakelselongswitch
caseenumregistertypedef
constexternreturnunion
charfloatshortunsigned
continueforsignedvolatile
defaultgotosizeofvoid
doifstaticwhile

We will use and learn these above keywords in our program whenever required.

Identifiers

Identifier is the unique name given to entities such as variables, functions, structures, etc. They are created to identify entities during the execution of program. For example:

Here, acountNumber and balance are the identifiers. Keep in the mind that the name of identifiers must be different from keywords. You can't use int as an identifier because int is a reserved keywords of C compiler.

Identifiers are a part of the Basic Programming Elements of the C Programming Language while Variables, Constants, Literals, etc. are other Basic Elements / Sub-Elements. Without a proper understanding these identifier the C Language cannot be understand properly. Same as for other Programming Language, because these Basic Elements are equally exist not only in C Language but any other Programming Language.

Rules for naming identifiers

  • Any upper case and lower case character can be used in the name of any identifier.
  • Underscore can also be used in the name of any identifier.
  • If we want to use digits in the name of any identifier, it is necessary to have at least one character or underscore before using the digits.
  • Apart from this, any type of Special Symbol such as Period, Comma, Blank Space etc. cannot be used in the name of the identifier. Also, we cannot use the name of a Reserve Word or a Built-In Function in the name of an identifier.
  • The name of identifier cannot be starts with a digit.
  • Reserved keyword cannot be used as identifier.

"C" is a case sensitive language, so the names of capital letters and small letters are considered as different in this language. Like int Sum and int sum are two different variable name or identify and not same.

Right way to declare variable identifier

We can name any variable identifier or constant identifier in any of the following ways, which completely follow the naming conventions of "C":

number
number2
amount_of_sale
_amount
salary
daysOfWeek
monthsOfYear

Wrong way to declare variable identifier

The below names are declared wrong and we cannot accept the names of these types to any variable or constant identifier, because these names do not follow the naming rules of "C" Language:

number#illegal use of special symbol #
number2*illegal use of special symbol *
1amount_of_salename could not start with a digit
&$amountillegal use of special symbol & and $
days Of Weekillegal use of special symbol blank space
months OfYear10illegal use of special symbol blank space