Ads 468x60px

Labels

Thursday, 6 September 2012

Keywords,Variables and Constants in C

"Keywords" are words that have special meaning to the C compiler.Keywords are also called Reserved words.
Following are the keywords of C language

                                                          32 keyword's in C language

Variables

Variable is a meaningful name of data storage location in computer memory. When using a variable you refer to memory address of computer.
Rules for writing variables
  • Variable names can consist of:
    • Letters
    • Digits
    • Underscores
    Example: "num1" to store the first of 3 numbers
  • Variable names cannot start with a digit.
  • Example: "3integers" is illegal
  • Variable names should not start with an underscore.
    Example: Avoid the use of variable names like "_number"
  • Variable names should consist of 31 or fewer characters to ensure portability.
  • Variable names should be descriptive of their use.
    Example: "grade" would be a good name to use for a variable that stores
    a student's test grade.
  • Variable names are case sensitive.
    Example: "x1" is not the same as "X1"
  • Keywords such as "int" and "float" cannot be used as variable names.

Constants

A "constant" is a number, character, or character string that can be used as a value in a program. Use constants to represent floating-point, integer, enumeration, or character values that cannot be modified.
                                                                       or
constant is an entity that doesn't change during the execution of a program.

There are four categories of constants in C:

  • Integer constants (such as 63 , 0 , and 42L )
  • Floating-point constants (such as 1.2 , 0.00 , and 77E+2 )
  • Character constants (such as 'A' , '0' , and L'\n' )
  • Enumeration constants (such as enum boolean { NO, YES }; ), where NO and YES are the enumeration constants