Program for "size of " operator in C++

size of operator returns the size of the given data type.
 
syntax:
 sizeof(datatype);


Program for "size of " operator in C++:

#include<iostream>
using namespace std;
int main()
{
cout<<"\nsize of int is "<<sizeof(int);
cout<<"\nsize of short int is "<<sizeof(short int);
cout<<"\nsize of char is "<<sizeof(char);
cout<<"\nsize of double is "<<sizeof(double);
cout<<"\nsize of float is "<<sizeof(float);
return 0;
}

Output:
size of int is 4
size of short int is 2
size of char is 1
size of double is 8
size of float is 4
  

Comments