Sunday, 24 June 2012

what is data type in c++



Fundamental data types
When programming, we store the variables in our computer's memory, but the computer has to know what kind of data we want to store in them, since it is not going to occupy the same amount of memory to store a simple number than to store a single letter or a large number, and they are not going to be interpreted the same way.

The memory in our computers is organized in bytes. A byte is the minimum amount of memory that we can manage in C++. A byte can store a relatively small amount of data: one single character or a small integer (generally an integer between 0 and 255). In addition, the computer can manipulate more complex data types that come from grouping several bytes, such as long numbers or non-integer numbers.
What is a data type?
When we wish to store data in a C++ program, such as a whole number or a character, we have to tell the compiler which type of data we want to store. The data type will have characteristics such as the range of values that can be stored and the operations that can be performed on variables of that type


Next you have a summary of the basic fundamental data types in C++, as well as the range of values that can be represented with each one:


Name
Description
Size*
Range*
char
Character or small integer.
1byte
signed: -128 to 127
unsigned: 0 to 255
short int(short)
Short Integer.
2bytes
signed: -32768 to 32767
unsigned: 0 to 65535
int
Integer.
4bytes
signed: -2147483648 to 2147483647
unsigned: 0 to 4294967295
long int (long)
Long integer.
4bytes
signed: -2147483648 to 2147483647
unsigned: 0 to 4294967295
bool
Boolean value. It can take one of two values: true or false.
1byte
true or false
float
Floating point number.
4bytes
+/- 3.4e +/- 38 (~7 digits)
double
Double precision floating point number.
8bytes
+/- 1.7e +/- 308 (~15 digits)
long double
Long double precision floating point number.
8bytes
+/- 1.7e +/- 308 (~15 digits)
wchar_t
Wide character.
2 or 4 bytes
1 wide character




2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. thank you for sharing nice article in your blog
    visit
    web programming tutorial
    welookups

    ReplyDelete