← 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?
- A.malloc(10)
- B.malloc(10 * sizeof(int))
- C.malloc(sizeof(10))
- 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 →