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);

User Jpkotta
by
4.9k 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.

User Slacktracer
by
5.5k points