Consider the following. char c='a'; char d=c+1; //line 1. char e=4+4; //line 2. I know line 1 gives error as it requires explicit casting. I do not understand why line 2 does not give an error. 4+4 results in 8 which is of type int. why does it not require an explicit casting?
4 is an int literal and also a compile time constant. When you add two constants to each other, the result is a constant as well. In this case, if the resulting int const fits into char, the compiler allows such an assignment.