ExamVeda
Login
Home
This question belongs to C Program Arrays And Strings
Arrays and Strings
?

Consider the following type definition.
typedef char x[10];
x myArray[5];

What will sizeof(myArray) be ? (Assume one character occupies 1 byte)

Answer & Solution
Correct Answer: Option C
In this case, the type definition typedef char x[10]; creates a new type x, which is an array of 10 characters. Then, an array of 5 elements of type x is declared as x myArray[5];.

To calculate the size of myArray, you can multiply the size of one element (sizeof(x)) by the number of elements (5):

sizeof(myArray) = sizeof(x) * 5

Since each element x is an array of 10 characters, and assuming each character occupies 1 byte, the size of x is 10 bytes. Therefore:

sizeof(myArray) = 10 bytes * 5 = 50 bytes

So, sizeof(myArray) will be 50 bytes.
Examveda
Question posted by Examveda
Community

Join the Discussion

16 Comments
Rahul Sonkar
Rahul Sonkar 3 years ago
Expalin
Gayatri Kambale
Gayatri Kambale 4 years ago
plz explain this question
Pooja Kangula
Pooja Kangula 6 years ago
Explain
Samayra Mayra
Samayra Mayra 6 years ago
typedef char x[10];
X myArray[5];
X=5
Then
5*10=50
Jitesh Joshi
Jitesh Joshi 6 years ago
Array name rplace it with the value of first index I think ??
Sharvari Patil
Sharvari Patil 7 years ago
its basically like 2 dimension array
so: 10*5=50
10 of X and 5 of myarray
Supriya Pallapothu
Supriya Pallapothu 8 years ago
explain
Vageshwar Yadav
Vageshwar Yadav 8 years ago
They have only asked the size of the array so we have to consider null character too.
since myarray = 5 and x = 10
therefore, 5 * 10 = 50
Ankit Pandit
Ankit Pandit 9 years ago
already mention that character is one byte so x=10;
therefore x myarray[5] it means 10*5=50 is the right answer.]
Navya Sanjji
Navya Sanjji 9 years ago
can someone explain me how it is?
Vamsi Kolukulapalli
Vamsi Kolukulapalli 9 years ago
10*5=50
Pavithra Selvam
Pavithra Selvam 9 years ago
explain it. how this answer is possible?
Shaik Salma
Shaik Salma 9 years ago
how it can be 50?
Indhu Nila
Indhu Nila 9 years ago
how it is 50?
Indhu Nila
Indhu Nila 9 years ago
how it is 50?
Aanchal Sardana
Aanchal Sardana 10 years ago
how it wud b 0?