Examveda
Examveda

short testarray[4][3] = { {1}, {2,3}, {4,5,6}};
printf("%d", sizeof(testarray));

Assuming a short is two bytes long, what will be printed by the above code?

A. 6

B. 7

C. 12

D. 24

E. It will not compile because not enough initializers are given

Answer: Option D

Solution(By Examveda Team)

The following table provides the details of standard integer types with their storage sizes and value ranges −

Type Storage size Value range
char 1 byte -128 to 127 or 0 to 255
unsigned char 1 byte 0 to 255
signed char 1 byte -128 to 127
int 2 or 4 bytes -32,768 to 32,767 or -2,147,483,648 to 2,147,483,647
unsigned int 2 or 4 bytes 0 to 65,535 or 0 to 4,294,967,295
short 2 bytes -32,768 to 32,767
unsigned short 2 bytes 0 to 65,535
long 4 bytes -2,147,483,648 to 2,147,483,647
unsigned long 4 bytes 0 to 4,294,967,295

This Question Belongs to C Program >> C Fundamentals

Join The Discussion

Comments ( 10 )

  1. Harsh Hitesh
    Harsh Hitesh :
    6 years ago

    thanks abhijeet !

  2. Vijay Vijju
    Vijay Vijju :
    6 years ago

    4*3=12
    12*2(int type)=24

  3. Prit Shah
    Prit Shah :
    7 years ago

    Not proper explanation

  4. Ishita Arora
    Ishita Arora :
    7 years ago

    Please Give the explaination

  5. Prakash Lakhara
    Prakash Lakhara :
    7 years ago

    how can that be?

  6. Mayuri Upadhye
    Mayuri Upadhye :
    7 years ago

    Please explain this..??

  7. Deepmala Deepmala
    Deepmala Deepmala :
    7 years ago

    how ans d came??

  8. Shital Pingale
    Shital Pingale :
    7 years ago

    kas kay he as??

  9. Media Research
    Media Research :
    7 years ago

    How it possible?

  10. Abhijeet Chimankar
    Abhijeet Chimankar :
    8 years ago

    We have already defined the array size as 4*3. So, there will be 4*3=12 short nos. stored.
    Each short is two bytes long. So, 12short * 2bytes = 24 bytes [size of array]

Related Questions on C Fundamentals