The data type used to store real values
The data type used to store real values


The data type used to store real values

Data Types: A Data type is a type of data. Data types can be used C++ Program.C++ language provides different data types. which can be used in the C++ language program. Data types provide in the C++ library.

Data types are two types in C++ Language 

1. Pre-defined Data Types

2. User-defined Data Types or Derived Data Types.

Pre-defined Data Types: A pre-defined data type is also provided already define in C++ Library. pre-defined data types like integer, floating and Character are pre-defined data types in C++ Language.

Important Same Other Languages Data_Types

👉C Data Types

👉Java Data Types 

👉Python Data Types


Pre-defined data Types Basic Types

1.integer Type (int)

2.floating Type(float)

3.Character Type(char)


User-defined Data Types or Derived Data Types.

1. Pointer Types

2. Array

3. Structure

4. Union


Size of integer Data types

Data Types   Size    Bytes  Range

short                 2      -32768 To +32767

int                      2      -32768 To +32767

unsigned int     2       0 To +65536

long                  4          -214748 To +214748

unsigned long  4      0 To 4,294,967


Size of float Data types

Data Types    Size Bytes  Range

float                4      3.4E-38 To +3.4E+38

double            8       1.7+308 To +1.7E+308

long double   10       3.4-4932 To +1.1+4932


Size of char Data types

Data Types    Size in Bytes    Range

char                           1     -127 To +128

signed char              1     -128 To -128

signed char              1      -0 To + 255


How To Use Data Types Size in C++?

#include <iostream>


#include <stdlib.h>


#include <limits.h>


#include <float.h>


using namespace std;


int main() 


{


int args;


char** args;


cout<<"CHAR_BIT:"<<CHAR_BIT<<"\n";


cout<<"CHAR_MAX:" <<CHAR_MAX<<"\n";


cout<<"CHAR_MIN:"<<CHAR_MIN<<"\n";


cout<<"INT_MAX:"<<INT_MAX<<"\n";


cout<<"INT_MIN:"<<INT_MIN<<"\n";


cout<<"LONG_MAX:"<<LONG_MAX<<"\n";


cout<<"LONG_MI:"<<LONG_MIN<<"\n";


cout<<"SCHAR_MAX:"<<SCHAR_MAX<<"\n";


cout<<"SCHAR_MIN:"<<SCHAR_MIN<<"\n";


cout<<"SHRT_MAX:"<<SHRT_MAX<<"\n";


cout<<"SHRT_MIN:"<<SHRT_MIN<<"\n";


cout<<"UCHAR_MAX:"<<UCHAR_MAX<<"\n";


cout<<"UINT_MAX:"<<UINT_MAX<<"\n";


cout<<"ULONG_MAX:"<<ULONG_MAX<<"\n";


cout<<"USHRT_MAX:"<<USHRT_MAX;


return 0;


}


*****OUTPUT*****


CHAR_BIT    :   8


CHAR_MAX    :   127


CHAR_MIN    :   -128


INT_MAX     :   2147483647


INT_MIN     :   -2147483648


LONG_MAX    :   2147483647


LONG_MIN    :   -2147483648


SCHAR_MAX   :   127


SCHAR_MIN   :   -128


SHRT_MAX    :   32767


SHRT_MIN    :   -32768


UCHAR_MAX   :   255


UINT_MAX    :   4294967295


ULONG_MAX   :   4294967295


USHRT_MAX   :   65535


How To Use float Data Types in C++?

#include <iostream>


#include <stdlib.h>


#include <limits.h>


#include <float.h>


using namespace std;


int main() 


{


int args; 


char** args;


cout<<"Storage size for float :"<<sizeof(float)<<"\n";


cout<<"FLT_MAX: "<<(float) FLT_MAX<<"\n";


cout<<"FLT_MIN: "<<(float) FLT_MIN<<"\n";


cout<<"-FLT_MAX: "<<(float) -FLT_MAX<<"\n";


cout<<"-FLT_MIN: "<<(float) -FLT_MIN<<"\n";


cout<<"DBL_MAX: "<<(double) DBL_MAX<<"\n";


cout<<"DBL_MIN: "<<(double) DBL_MIN<<"\n";


cout<<"Precision: "<<FLT_DIG<<"\n";


return 0;


}


*****OUTPUT*****


Storage size for float:4


FLT_MAX: 3.40282e+038


FLT_MIN: 1.17549e-038


-FLT_MAX: -3.40282e+038


-FLT_MIN: -1.17549e-038


DBL_MAX: 1.79769e+308


DBL_MIN: 2.22507e-308


Precision: 6