ExamVeda
Login
Home
This question belongs to C Program C Fundamentals
C Fundamentals
?

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?

Answer & Solution
Correct Answer: Option D

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
Examveda
Question posted by Examveda
Community

Join the Discussion

11 Comments
Anubhavi Gaur
Anubhavi Gaur 2 years ago
See basically this says that if sort is 2bytes long then what is the output, we can see that the size of the test array is given as [4][3] which simply suggest that total size of the array will be 12 and the short having the storage of 2 bytes that's why it will be 12*2=24
I hope this will be helpful for you!!
Harsh Hitesh
Harsh Hitesh 8 years ago
thanks abhijeet !
Vijay Vijju
Vijay Vijju 8 years ago
4*3=12
12*2(int type)=24
Prit Shah
Prit Shah 9 years ago
Not proper explanation
Ishita Arora
Ishita Arora 10 years ago
Please Give the explaination
Prakash Lakhara
Prakash Lakhara 10 years ago
how can that be?
Mayuri Upadhye
Mayuri Upadhye 10 years ago
Please explain this..??
Deepmala Deepmala
Deepmala Deepmala 10 years ago
how ans d came??
Shital Pingale
Shital Pingale 10 years ago
kas kay he as??
Media Research
Media Research 10 years ago
How it possible?
Abhijeet Chimankar
Abhijeet Chimankar 10 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]