Let us know about
different data type.
While doing programming in any
programming language, you need to use various variables to store various
information.
You may like to store information of
various data types like character, wide character, integer, floating point,
double floating point, boolean etc.
Following
table lists down seven basic C++ data types:
Type
|
Keyword
|
Boolean
|
Bool
|
Character
|
Char
|
Integer
|
Int
|
Floating
point
|
Float
|
Double
floating point
|
Double
|
Valueless
|
Void
|
Wide
character
|
wchar_t
|
Several of the basic data
types can be modified using one or more of these type modifiers:
·
signed
·
unsigned
·
short
·
long
The
following table shows the variable type, how much memory it takes to store the
value in memory, and what their typical range is
Type
|
Typical
Bit Width
|
Typical
Range
|
Char
|
1byte
|
-127
to 127 or 0 to 255
|
unsigned
char
|
1byte
|
0 to
255
|
signed
char
|
1byte
|
-127
to 127
|
Int
|
4bytes
|
-2147483648
to 2147483647
|
unsigned
int
|
4bytes
|
0 to
4294967295
|
signed
int
|
4bytes
|
-2147483648
to 2147483647
|
short
int
|
2bytes
|
-32768
to 32767
|
unsigned
short int
|
Range
|
0 to
65,535
|
signed
short int
|
Range
|
-32768
to 32767
|
long
int
|
4bytes
|
-2,147,483,648
to 2,147,483,647
|
signed
long int
|
4bytes
|
same
as long int
|
unsigned
long int
|
4bytes
|
0 to
4,294,967,295
|
Float
|
4bytes
|
+/-
3.4e +/- 38 (~7 digits)
|
Double
|
8bytes
|
+/-
1.7e +/- 308 (~15 digits)
|
long
double
|
8bytes
|
+/-
1.7e +/- 308 (~15 digits)
|
wchar_t
|
2 or
4 bytes
|
1
wide character
|
Let us take example program use different data type …
#include<iostream.h>
Void main()
{
int a,b,sum,sub;
long int multiplay;
float divide;
cout<<”provide
the value of a and b”;
cin>>a>>b;
sum=a+b;
sub=a-b;
multiplay=a*b;
divide=a/b;
cout<<”value
after addition”<<sum;
cout<<”value
after subtraction”<<sub;
cout<<”value
after multiplication”<<multiplay;
cout<<value
after division:<<divide;
}
Explaination:
Cin-> it is used to
provide the value by user
Syntax-cin>>variable;
cout-> it is used
to display the output or any content
Syntax-
cout<<"Content";
2 comments
commentshey guys,if any doubt in this tutorial then write to me .i am always there to help you...
Replyhey guys,if any doubt in this tutorial then write to me .i am always there to help you...
Reply