Saturday, 28 December 2013

Filled Under:

Data Type in C++:

Data Type in C++:

we store variable in computer memory. but computer has to know what kind of data we store in a variable. for this purpose we use data type that tell the computer what kind of data we are store in a variable.

There are 4 basic data types  :



  • int
  • char
  • float
  • double


int:

—used to declare numeric program variables of integer type whole numbers, positive and 
negative
—keyword: int
Range :
 signed: -2147483648 to 2147483647 
unsigned: 0 to 4294967295
Size     : 1byte

char: 

—equivalent to ‘letters’ in English language
—Example of characters:
—Numeric digits: 0 - 9
—Lowercase/uppercase letters: a - z and A - Z
—Space (blank)
—Special characters: , . ; ? “ / ( ) [ ] { } * & % ^ < > etc
—single character
—keyword: char
Range :
signed: -128 to 127
unsigned: 0 to 255
Size: 4 byte

Float:

—fractional parts, positive and negative
—keyword: float
Range    :+/- 3.4e +/- 38
Size        : 4 byte

Double:

—used to declare floating point variable of higher precision or higher range of numbers
exponential numbers, positive and negative
—keyword: double
Range    : +/- 1.7e +/- 308 
Size        :  8 byte




0 comments:

Post a Comment