What is the size of the array in the code shown below.(Assume l character occupies 1 byte)
typedef char a[10];
a myarray[5];
Select one:
A. 10 bytes
B. 40 bytes
C.50 bytes
D.5 bytes
Answers
Answer:
50 bytes
Step-by-step explanation:
1 byte for character
a[10] -- 10 bytes
myarray[5] --- 5*10 = 50 bytes
Concept: A group of items kept in consecutive memory regions is known as an array. The goal is to group objects of the same category for storage. As a result, it is simpler to determine each element's position by simply adding an offset to a base value, or the address in memory where the array's first element is stored (generally denoted by the name of the array). Index 0 serves as the basis value, and the offset is the difference between the two indices.
Given: the code
typedef char a[10];
a myarray[5];
To find: the size of the array
Solution: myarray will have a size of 50 bytes. The character array x, which is 10 characters long, has been defined in the code above. As a result, the code's output is 10 * 5, or 50 bytes.
Hence, the size of the array is 50 bytes.
#SPJ2