- a set of values -32768 to +32767
- and predefined operations on these values like +(addition), - (subtraction), *(mutplication) and / (division) etc.
Basic data Types in C++
There are the following data types in C++.
- integer data types ( int, short int, long int, unsigned int, unsigned long int)
- real data types (float, double, long double)
- char
1. Integer Data Types
Integer data types deal with whole numbers. We will define integer variables to store and operate whole numbers. Integer data type is used to define integer variables. integer variables can hold whole numbers that is numbers without fractions or decimal point. For example 100, 8, 991, -2, 786 and 32400 are whole numbers. These whole numbers will range from -32768 to 32767.Now we can divide integer data types in to some categories according to the memory space they take and the range of whole numbers they can deal with.
int data type deal with whole numbers. in MS-DOS, a variable of int data type takes two bytes in memory. It can store values between the range -32768 to +32767.
- int data type
short int data type can store whole numbers from -32768 to +32767. A variable of short int data type will take two bytes in memory.
- short int data type
long int data type is used to store large whole numbers. It takes four bytes in memory. Its range is from -2,147,483,648 to 2,147,483,647.
- long int data type
It is used to store only positive whole numbers from 0 to 65,535. Its variable takes two bytes in memory.
- unsigned int data type
It is used to store only positive whole numbers from 0 to 4,294,967,295. Its variable takes four bytes in memory.
- unsigned long int data type
2. Real Data Types
Real data types deal with real numbers, that is, numbers with factional parts or decimal points like 4.50, -90.20, 2.49 and 999.99 etc.float data type deals with real numbers. A variable of float data type will hold four bytes in memory. It can store real values from 3.4x10-38 to 3.4x10+38. A float variable can store real numbers with accuracy of 6 decimal places.
- float data type
double data type deals with large real numbers. A variable of double data type will hold eight bytes in memory. It can store real values from 1.7x10-308 to 1.7x10+308. Moreover, a double variable can store real numbers with accuracy up to 15 decimal places.
- double data type
double data type deals with very large real numbers. A variable of long double data type will hold ten bytes in memory. It can store real values from 1.7x10-4932 to 1.7x10+4932. Moreover, a long double variable can store real numbers with accuracy up to 19 decimal places.
- long double data type
0 comments:
Post a Comment
We Love To Hear From You!