C Programming and Data Structures: Unit I: C Programming Fundamentals

Keywords, Variables and Constants

C Programming

• These are basically the reserved words which have special meaning. The meaning of keywords cannot be changed.

Keywords, Variables and Constants

 

Keywords:

Keywords are the standard words in C.

• These are basically the reserved words which have special meaning. The meaning of keywords cannot be changed.

• All keywords are written in lower case.

• Various keywords used in C are listed below -


 

Identifiers :

• Identifier is a collection of alphanumeric characters in which the first character must not be numeric.

• Identifiers are the names given to the variables, functions or constants.

• The name of the identifier must not be the keyword

 

Validity of variable names

Following are the rules which should be followed while deciding the variable names

1) The first letter of the variable must not be digit or any special character.

2) Special characters (such as $, #, %) are not allowed in the variable name except underscore.

3) The variable name is case sensitive. A variable name can be in capital letters.

4) The length of the variable name can be any but only first 31 characters are recognized.

5) The keywords are not valid variable names.

6) Blank spaces or special characters, commas, use of quotes are not allowed in the variable name.

7) Arithmetic operators should not be used in the variable names.

The variable names should be informative. It should describe the purpose of it by its name.

The valid variables are

Count,tax_id,INDEX,Xyz,brick01

The invalid variable names are

_file,char,#id, 1A,valid name

 

Constants

Definition of constant: The specific alphabetical or numerical value that never gets changed during the processing of the instructions is called as constant.

• The constant can be alphabetical, numeric or special symbol.

• The constants are given some names and are referred by the names.

• Example: The most commonly used constant is PI. Once the value to this constant is assigned then it does not get changed.ohcorl tugi

• The names to the constant help in accessing them easily.

• Generally all the letters in the name of the constant are capital.

Comparison between Constants and Variables


 

C Programming and Data Structures: Unit I: C Programming Fundamentals : Tag: : C Programming - Keywords, Variables and Constants