Examveda
Examveda

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

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

A. 15

B. 10

C. 50

D. 30

E. None of these

Answer: Option C

Solution(By Examveda Team)

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.

This Question Belongs to C Program >> Arrays And Strings

Join The Discussion

Comments ( 16 )

  1. Rahul Sonkar
    Rahul Sonkar :
    8 months ago

    Expalin

  2. Gayatri Kambale
    Gayatri Kambale :
    1 year ago

    plz explain this question

  3. Pooja Kangula
    Pooja Kangula :
    3 years ago

    Explain

  4. Samayra Mayra
    Samayra Mayra :
    3 years ago

    typedef char x[10];
    X myArray[5];
    X=5
    Then
    5*10=50

  5. Jitesh Joshi
    Jitesh Joshi :
    4 years ago

    Array name rplace it with the value of first index I think ??

  6. Sharvari Patil
    Sharvari Patil :
    4 years ago

    its basically like 2 dimension array
    so: 10*5=50
    10 of X and 5 of myarray

  7. Supriya Pallapothu
    Supriya Pallapothu :
    6 years ago

    explain

  8. Vageshwar Yadav
    Vageshwar Yadav :
    6 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

  9. Ankit Pandit
    Ankit Pandit :
    6 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.]

  10. Navya Sanjji
    Navya Sanjji :
    6 years ago

    can someone explain me how it is?

  11. Vamsi Kolukulapalli
    Vamsi Kolukulapalli :
    7 years ago

    10*5=50

  12. Pavithra Selvam
    Pavithra Selvam :
    7 years ago

    explain it. how this answer is possible?

  13. Shaik Salma
    Shaik Salma :
    7 years ago

    how it can be 50?

  14. Indhu Nila
    Indhu Nila :
    7 years ago

    how it is 50?

  15. Indhu Nila
    Indhu Nila :
    7 years ago

    how it is 50?

  16. Aanchal Sardana
    Aanchal Sardana :
    7 years ago

    how it wud b 0?

Related Questions on Arrays and Strings