asked 6.4k views
1 vote
Consider the following declaration: int alpha[5] = {3, 5, 7, 9, 11};. Which of the following is equivalent to this statement? int alpha[] = {3, 5, 7, 9, 11}; int alpha[] = {3 5 7 9 11}; int alpha[5] = {3, 5, 7, 9 11}; int alpha[4] = (3, 5, 7, 9, 11);

asked
User Jpkotta
by
7.8k points

1 Answer

3 votes

Answer:

int alpha[] = {3, 5, 7, 9, 11}

Explanation:

int alpha[5] declares a list of 5 items. The values within the brackets needs to be separeted by commas, otherwise it'd produce an error. You can declare a list without specifying its size in the square brackets if you also declare its values, so the compiler will give reserve the memory needed.

Last satement gives also an error because the size declared does not match with the amount of items.

answered
User Slacktracer
by
8.2k points

No related questions found

Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.