Thursday, 3 January 2013

Variables in C


Character Set :

A character refers to the digit, alphabet or special symbol used to data represetation.
  1. Alphabets :                 A-Z, a-z
  2. Digits :                       0-9
  3. Special Characters :    ~ ! @ # $ % ^ & * ( ) _ + { } [ ] - < > , . / ? \ | : ; " '
  4. White Spaces :            Horizontal tab, Carriage return, New line, form feed

Identifier :

Identifier is the name of a variable that is made up from combination of alphabets, digits and underscore.

Variable :

It is a data name which is used to store data and may change during program execution. It is opposite to constant. Variable name is a name given to memory cells location of a computer where data is stored.
* Rules for varibales:
  1. First character should be letter or alphabet.
  2. Keywords are not allowed to use as a variable name.
  3. White space is not allowed.
  4. C is case sensitive i.e. UPPER and lower case are significant.
  5. Only underscore, special symbol is allowed between two characters.
  6. The length of indentifier may be upto 31 characters but only only the first 8 characters are significant by compiler.
  7. (Note: Some compilers allow variable names whose length may be upto 247 characters. But, it is recommended to use maximum 31 characters in variable name. Large variable name leads to occur errors.)

Keywords :

Keywords are the system defined identifiers.
All keywords have fixed meanings that do not change.
White spaces are not allowed in keywords.
Keyword may not be used as an indentifier.
It is strongly recommended that keywords should be in lower case letters.
There are totally 32(Thirty Two) keywords used in a C programming.
intfloatdoublelong
shortsignedunsignedconst
ifelseswitchbreak
defaultdowhilefor
registerexternstaticstruct
typedefenumreturnsizeof
gotounionautocase
voidcharcontinuevolatile


Escape Sequence Characters (Backslash Character Constants) in C:

C supports some special escape sequence characters that are used to do special tasks.
These are also called as 'Backslash characters'.
Some of the escape sequence characters are as follow:
Character ConstantMeaning
\nNew line (Line break)
\bBackspace
\tHorizontal Tab
\fForm feed
\aAlert (alerts a bell)
\rCarriage Return
\vVertical Tab
\?Question Mark
\'Single Quote
\''Double Quote
\\Backslash
\0Null

No comments:

Post a Comment