Consider that int take 4 bytes in memory.
to understand what I'm looking for take this example :
for(x=0;x<10;x++)
//do something
in this for instruction I know that the value of x is less than 11,
I have seen lot of code and most people declare x like an int,
why we shouldn't or why most people doesn't declare x like a short or even like a char !!
I thought in the reason and I found this explanation, for example :
short s=5;
s take 2 bytes in memory, and what I know is that the compiler consider 5 like an int so to put 5 to s, 5 should be converted to short right !!
-> so this instruction take less memory but more work
int i=5;
here i take 4 bytes but with no need for conversation (5 is an int)
-> so this instruction do less work but take more memory
is the reason something like what I thought !!
I hope that my question was clear