C++ Program to demonstrate sizeof operator
Program
#include<iostream>
using namespace std;
int main()
{
cout << "Size of char:\t\t" << sizeof(char) << endl;
cout << "Size of int:\t\t" << sizeof(int) << endl;
cout << "Size of short int:\t" << sizeof(short int) << endl;
cout << "Size of long int:\t" << sizeof(long int) << endl;
cout << "Size of float:\t\t" << sizeof(float) << endl;
cout << "Size of double:\t\t" << sizeof(double) << endl;
cout << "Size of wchar_t:\t" << sizeof(wchar_t) << endl;
return 0;
}
Output
Size of char: 1
Size of int: 4
Size of short int: 2
Size of long int: 4
Size of float: 4
Size of double: 8
Size of wchar_t: 4