🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Dynamic Memory: all 10 questions

Quiz: Dynamic Memory · Question 3 of 10

What is the correct way to allocate an array of 10 ints?

What is the correct way to allocate an array of 10 ints?

  1. A.malloc(10)
  2. B.malloc(10 * sizeof(int))
  3. C.malloc(sizeof(10))
  4. D.calloc(10)
Answer & explanation

Correct answer: malloc(10 * sizeof(int))

malloc takes bytes, so multiply by sizeof(int).

Can you get the rest right without peeking?

Take the timed Quiz: Dynamic Memory quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →