Variables
=========
What is a variable in a programming language. Everybody knows it is something which holds data. Before going to varibales we need to know
what kinds of data are there to be hold by varibale. In programming terminology kinds of data is called DataTypes.
Datatypes:
---------
There are four basic datatypes
1. int
2. float
3. char
4. double
Int:
====
Integer the name itself suggests the data it represents numbers both positive and negative.
Ex: 456778 , -894485
Float:
=====
Float the name itself suggests that it represents the data which is decimal
Ex:45.678, 0.9899 , 56.89
Char:
=====
Char the name suggests that it represents the data which is charcter.
Ex:a, b, c, d
Double:
=====
Same as floating point data type but larger floating values.
Ex:45.555555333 , 65.444448939
Memory Allocation
=================
Computers has to store data. How it will store data? Guess.I think u know that in terms of 0 and 1. Pity computer , Human Brain is Super Computer.
For storing either 0 or 1 computer requires one bit from its memory.
8bits = 1 byte
1024 bytes = 1kilo bytes(1KB)
1024kilobytes = 1 Megabytes(1MB)
1024Megabytes = 1gigabytes(1GB)
How our Datatypes are stored in Computer?
========================================
Definitely through 0 and 1. Every datatype must be converted into 0s and 1s.
a. How integers are stored ?
It will convert them into binary and store them.
b. How Float values are stored?
There is a IEEE floating point standard which will convert them into binary .
c. How chars are are stored?
Each charcter has ASCII values. Computer converts these ASCII values into binary
Memory stuff:
=============
DATATYPE BYTES
CHAR 1
INT 4
FLOAT 4
DOUBLE 8
Modifiers
==========
The data types explained above have modifiers . Means which will modify what kind of data they store and also how much it store
a. short
b. long
c. signed
d. unsigned
When we prefix signed to a datatype . You are modifying them to store both postive and negative . When we prefix unsigned we are only postive numbers
and short and long will make the size decrease and increase size respectively. If we dont specify anything it means signed.
BYTES
short int 2 (signed values)
unsigned short int 2 (unsigned values)
int 4 (signed values)
unsigned int 4 (signed values)
long int 4 (signed values) In 32bit processor and 64 bit processor it takes 8 bytes
unsigned long int 4 (unsigned values) In 32 bit processor annd 64 bit processor it takes 8 bytes
char 1 (signed chars)
unsigned char 1 (unsigned values)
You cannot prefix anything with float but only with double
long double 12
Next session will discuss about range and Qualifiers and Specifiers of Datatypes