1 1 vote What is the output of following program #include<stdio.h> int main() { short int i=20; char c=97; printf("%d,%d,%d\n",sizeof(i),sizeof(c),sizeof(c+i)); return 0; } (A)2,1,2 (B)2,1,1 (C)2,1,4 (D)2,2,8 Programming in C data-structures programming-in-c + – Robin Hoque 1.4k views answer comment Share Follow Print See all 5 Comments 5 5 Comments reply Show 2 previous comments Shubhanshu commented Aug 18, 2017 reply Follow flag it should be a) 0 0 replyShare arch commented Aug 23, 2017 reply Follow flag how u get 4 as output? 0 0 replyShare smsubham commented Sep 9, 2017 reply Follow flag Useful Read: https://stackoverflow.com/questions/24371868/why-must-a-short-be-converted-to-an-int-before-arithmetic-operations-in-c-and-c 0 0 replyShare Please log in or register to add a comment.
0 0 votes how sizeof(c+i)= 4 ??? Akash Verma 1 answered Aug 18, 2017 Akash Verma 1 comment Share Follow See 1 comment 1 1 comment reply smsubham commented Sep 9, 2017 reply Follow flag See this: https://stackoverflow.com/questions/24371868/why-must-a-short-be-converted-to-an-int-before-arithmetic-operations-in-c-and-c 0 0 replyShare Please log in or register to add a comment.
0 0 votes On most systems: sizeof(short int) = 2 So first output = 2sizeof(c) c is a char.sizeof(char) = 1In an arithmetic expression, C applies integer promotion rules:char and short are promoted to int before the operation. nirmal_aravind answered Nov 6, 2025 nirmal_aravind comment Share Follow 0 reply Please log in or register to add a comment.