A

Admin • 833.24K Points
Coach

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
", sizeof(a), sizeof(b), sizeof(b + a));
return 0;
}
  • (A) 2, 1, 1
  • (B) 2, 1, 4
  • (C) 2, 1, 2
  • (D) 2, 2, 8
  • Correct Answer - Option(B)
  • Views: 34
  • Filed under category C Programming
  • Hashtags:

Explanation by: Admin

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.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.