In the last Artifice on Binary and ASCII, we talked
about how Computers store all types of characters at Numbers, but if they are
numbers then how does the Computer understand whether to recognize some
particular bits as a number or as a character.
This is where Data Types come into play.
Every byte(8 bits) present in the Computer’s Memory
is designated a data type, some of the major data types are:
int : Integers ranging from -2,147,483,648 to 2,147,483,647
char: 256 Characters represented in ASCII
float: Numbers with decimal places upto 6 decimal
places
long long int: Integers ranging from -9,223,372,036,854,775,808 to
9,223,372,036,854,775,807
double :
Numbers with decimals upto 15 places
double
double: Numbers with decimals upto 19 places
void:
When some function is not to accept any input or give no output, Its said to be
void (This is not exactly a data type!)
bool :
Any Boolean expression which has a true/false value either zero or one is a
bool data type or Boolean data type.
Now,
Have you
wondered how are names stored in a Computer?
They are
stored as strings or a list of characters.
Every
string ends with a terminating null byte designated by ASCII 0 or \0;
In C++,
These’s a separate data type and list of functions for strings, Firstly, You
need to include the <string> library to store strings.
In C,
Strings could be designated using char pointers, we’ll get into that later.
Exercise
Try
implementing programs making use of the various data types in DevC++.
Comments
Post a Comment