Q. What is the output of the code below considering the size of “short int” is 2, “char” is 1 and “int” is 4 bytes?
Code:#include <stdio.h>
int main()
{
short int a = 20;
char b = 97;
printf("%d, %d, %d\n", sizeof(a), sizeof(b), sizeof(b + a));
return 0;
}
β
Correct Answer: (B)
2, 1, 4
Explanation: Whenever you have an operator like (+ – * / % << >> & | ^ == != < <= > >=) between two operands of different types, the two types are converted to a common type before the operation is performed.