This program shows how you can print the size of any data type available in C++ language. To find the size of any data type, C and C++ have one special operator sizeof. It simply calculates and returns the size of any given data type in bytes.

Program

#include <iostream>

using namespace std;

int main() {

    cout << "Type          Size (bytes)" << endl;
    cout << "Characte      " << sizeof(char) << endl;
    cout << "Integer       " << sizeof(int) << endl;
    cout << "Long int      " << sizeof(long int) << endl;
    cout << "Float         " << sizeof(float) << endl;
    cout << "Double        " << sizeof(double) << endl;
    cout << "Long double   " << sizeof(long double) << endl;

    return 0;
}

Output

Type Size (bytes)
Characte 1
Integer 4
Long int 8
Float 4
Double 8
Long double 16