Search This Blog

Friday, March 30, 2012

Constants and Variables-Constants


Constants

The C language is composed of seven basic types of code: Constants, Variables, Operators, Punctuations,
Keywords, Functions and Labels – collectively known as Tokens.

A constant is a named storage location in the memory where the compiler keeps unchanged data during program execution. Constants are of two types: Literal Constants and Symbolic Constants. A literal constant is a value that is directly used in the source code wherever it is needed.

E.g. int max = 100; integer constant
float tax = 0.05; floating point constant.
float multiplier = 2.03E-2 floating point constant (in scientific notation)

Integer constants can be written in three different notations.

  1. An integer constant starting with any digit other than 0 is treated as a decimal integer. It can contain a leading + 
  2. A constant starting with a 0 is treated as an octal integer. It can contain a leading + 
  3. A constant starting with a 0x or 0X is treated as a Hexadecimal integer. It can contain digits from 0 to 9 the letters A to F and a leading + or -.

No comments:

Post a Comment