Storage size and value range for Integer Data Type and Floating-Point Types - C++ Data Type

C++ examples for Data Type:Introduction

Introduction

Name of Data Type Storage SizeRange of Values
char 1 256 characters
bool 1 true (considered as any positive value)and false (which is a 0)
short int 2 -32,768 to +32,767
unsigned short int2 0 to 65,535
int 4 -2,147,483,648 to +2,147,483,647
unsigned int 4 0 to 4,294,967,295
long int 4 -2,147,483,648 to +2,147,483,647
unsigned long int 4 0 to 4,294,967,295

Floating-Point Data Types

TypeStorageAbsolute Range of Values (+ and -)
float 4 bytes1.40129846432481707 * 10-45 to 3.40282346638528860 * 10^38
double and long double 8 bytes4.94065645841246544 * 10-324 to 1.79769313486231570 * 10^308

Demo Code

#include <iostream>
using namespace std;
int main()//from   w ww  . j  a  v a  2 s  . com
{
   int num;
   num = 22;
   cout << "The value stored in num is " << num << endl;
   return 0;
}

Result


Related Tutorials