Consider the following type definition.
typedef char x[10];
x myArray[5];
What will sizeof(myArray) be ? (Assume one character occupies 1 byte)
typedef char x[10];
x myArray[5];
A. 15
B. 10
C. 50
D. 30
E. None of these
Answer: Option C
Solution(By Examveda Team)
In this case, the type definitiontypedef 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. Join The Discussion
Comments ( 16 )
Related Questions on Arrays and Strings
Expalin
plz explain this question
Explain
typedef char x[10];
X myArray[5];
X=5
Then
5*10=50
Array name rplace it with the value of first index I think ??
its basically like 2 dimension array
so: 10*5=50
10 of X and 5 of myarray
explain
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
already mention that character is one byte so x=10;
therefore x myarray[5] it means 10*5=50 is the right answer.]
can someone explain me how it is?
10*5=50
explain it. how this answer is possible?
how it can be 50?
how it is 50?
how it is 50?
how it wud b 0?