Friday 6 March 2015

Different Data Types in C++ Programming , int char long int double

Data types in C++   int cha r lo ng int d ouble e tc What is a Data type?  Its indicate to compiler that store whether integer v... thumbnail 1 summary

Data types in C++

 int char long int double etc

What is a Data type? 

Its indicate to compiler that store whether integer value or decimal or to store character value.
For example we are interesting to store the 2, 7 so we will need to declared two variables of data type int and the assign these value to the variables.






As you read about variable in previse lecture that every variable has its own data type. 

What is int?


int is a data type which can store integer value.

For example 2,10,4500
int a;
int b;
a=2;
b=7;
But if we are interesting to store the decimal value in our C++ program so we will use the data type float.

What is float?

float is a data type which can store decimal value as well as integer values.
For example 3.14, 5.8, 44.0
float a=1.3;
float b=4.3;
float c=10.0;
But if we are interesting to store the character or array of character in our C++ program so we will use the data type char.





What is char? 


char is a data type which can store character or array of characters .
For example A, abc, HaroonMuhammad
Char a=’A’;
Char b[3]=’a’,  ’b’  ,’c’;
char c[ ] =”HaroonMuhammad”;

b[3] means that it will store the three charterer and its syntax is given above. c[ ]means that it will store any number of character which will assign to it.

There are different data types and their memories reserved are given in the table.