SIZEOF OPERATOR
- This compile time operator is used to determine the size of variable/data type in bytes.
- Sizeof operator can also be used to determine size of user defined variables i.e. class, structures etc.
- Nesting of sizeof operator is possible .
//Program to display the size of different Datatypes
#include <iostream>
using namespace std;
int main()
{
cout<<"\n SIZE OF DIFFERENT DATATYPES \n";
cout<<"\n CHAR DATATYPE: "<< sizeof(char);
cout<<"\n BOOL DATATYPE: "<< sizeof(bool);
cout<<"\n WIDE CHARACTER: "<< sizeof(wchar_t);
cout<<"\n SHORT DATATYPE: "<< sizeof(short);
cout<<"\n INT DATATYPE: "<< sizeof(int);
cout<<"\n LONG DATATYPE: "<< sizeof(long);
cout<<"\n FLOAT DATATYPE: "<< sizeof(float);
cout<<"\n DOUBLE DATATYPE: "<< sizeof(double);
cout<<"\n LONG DOUBLE DATATYPE: "<< sizeof(long double);
return 0;
}
OUTPUT