sizeof operator in CPP

sizeof is a keyword. It determines the size in bytes of variables and datatypes as seen in the example.


#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();

cout << sizeof(int) << endl;
cout << sizeof(char) << endl;
cout << sizeof(float) << endl;
cout << sizeof(long) << endl;
cout << sizeof(double) << endl;
cout << sizeof(short) << endl;

getch();
}
Output:
2
1
4
4
8
2

Leave a Reply