Integer types smaller than int are promoted when an operation is performed on them. If all values โโof the original type can be represented as int, the value of the smaller type is converted to int; otherwise, it is converted to unsigned int.
Integer stocks require the promotion of each variable (c and i) to an int size.
short i = 20; char c = 97; //The two int values are added and the sum is truncated to fit into the char type. char a = c + i; printf("%d, %d, %d %d\n", sizeof(i), sizeof(c), sizeof(c + i),sizeof(a)); 2, 1, 4 1
Parag bafna
source share