C++ examples for Data Type:Introduction
Name of Data Type | Storage Size | Range 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 int | 2 | 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
Type | Storage | Absolute Range of Values (+ and -) |
---|---|---|
float | 4 bytes | 1.40129846432481707 * 10-45 to 3.40282346638528860 * 10^38 |
double and long double | 8 bytes | 4.94065645841246544 * 10-324 to 1.79769313486231570 * 10^308 |
#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; }