Search This Blog

Tuesday, 30 October 2012

Constants

string constants
Numeric constants
Character constants

String constant:

 A string constant is a sequence of alpha numeric characters enclosed in double quotation (") marks. The maximum length is 255 characters.

Numeric constants:

 Integer  -Integer
          -short Integer
          -long Integer
 Float    -Float
          -double

          -long double
 Unsigned -Unsigned char
          -Unsigned integer
          -Unsigned short int
          -Unsigned long int

 Hex      -Short hexadecimal
          -long hexadecimal
 Octal    -short octal
          -long octal

Integer Data:
 The keyword is transfer integer data type in c++ and size is either 16 or 32 bits

    16bits(2bytes) 32bits(4bytes)

Example:
 16 bit integer range -2^15 to 2^15-1
 32 bit integer range -2^31 to 2^31-1
 -32786 to 32767

Short integer Data type:

 The maximum size is 16 bits long

Long integer Data type:
 The maximum size is 32 bits integer range is -2^31 to 2^31-1

Floating point constant:
 Positive and negative number represented inexponential form. Floating-point constants specify values that must have a fractional part. These values contain decimal points (.) and can contain exponents.

Floating point data type:
 The number which are store in the form of floating point representation with mantissa and exponent are called as floating point numbers.
 

Double data type:
 Double is a keyword to represent double precision floating point numbers.

Long double data type:
 Any number (digits 0-9)containing a decimal point(.) and followed by L or l 

(e.g)
2.345234E8l// a long double constant

Unsigned char:
 Unsigned char, which gives you at least the 0 to 255 range is called unsigned char.

Unsigned int:
 unsigned int has a range of 0 - 65535 range is called unsigned integer.
 

Unsigned short int:
 Declare a 'const unsigned short' object with an appropriate name and then use that in place of the 23. It still doesn't help you explicitly state that 23 is intended to be unsigned short, but at least you only need to check that declaration to ensure correctness. Everywhere else will use the constant and so the meaning will be clear.
 Unsigned short int has a range of 0-65535 (2-bytes) Type name is Unsigned int other name is unsigned short int.

Unsigned long int:
 Unsigned long is 0-4294967295 (4-bytes) other name is Unsigned long int

Hexa decimal constant:
 (base 16) begin with a 0x or 0x prefix, followed by a hexadecimal number represented by a combination of digit 0-9 and characters A-F

Octal constant:
 (base 8) consist of one or more digits 0-7 where the first digit is 0

Character constant:
 A character represented with in the single quotes(') we denotes the character constants.
(e.g)
 'A','i'
 

No comments:

Post a Comment