i think that in c++ every int takes 2 Bytes of the ram.
but in this program output shows 4 Bytes
i'll be thankful if someone help
#include "iostream"
#include "conio.h"
using namespace std;
int main()
{
cout<<"The size is "<<(sizeof(int));
return 0;
}
--------
output
The size is 4
--------
why does this happen?
i think that in c++ every int takes 2 Bytes of the ram.
You think wrong.
'int' must be at least 2 bytes, but can be larger. From what I understand it is typically whatever size is most 'natural' for the OS to work with so it gets peak performance. On modern computers that would be at least 32-bit... possibly 64-bit (though I think most implementations are still 32-bit ints).