C++ Fundamental Data Types: Notes Code
#include "iostream.h"
void main()
{
cout << "short size: " << sizeof ( short) <<endl;
cout << "unsigned short size: " << sizeof ( unsigned short) <<endl;
cout << "int size: " << sizeof ( int ) <<endl;
cout << "unsigned int size: " << sizeof ( unsigned int ) <<endl;
cout << "long size: " << sizeof ( long) <<endl;
cout << "unsigned long size: " << sizeof ( unsigned long) <<endl;
cout << "double size: " << sizeof ( double) <<endl;
cout << "long double size: " << sizeof ( long double) <<endl;
cout << "float size: " << sizeof ( float ) <<endl;
cout << "bool size: " << sizeof ( bool) <<endl;
cout << "char size: " << sizeof ( char ) <<endl;
cout << "unsigned char size: " << sizeof ( unsigned char ) <<endl;
cout << "signed char size: " << sizeof ( signed char ) <<endl;
}
Output:
short size: 2
unsigned short size: 2
int size: 4
unsigned int size: 4
long size: 4
unsigned long size: 4
double size: 8
long double size: 8
float size: 4
bool size: 1
char size: 1
unsigned char size: 1
signed char size: 1