235k views
2 votes
Which of the following is a valid C++ array definition?

A.
int array[0];

B.
float $payments[10];

C.
void numbers[5];

D.
int array[10];

User Tom Udding
by
5.0k points

1 Answer

2 votes

Answer:

The correct answer for the given question is option(D) i.e int array[10];

Step-by-step explanation:

As array is the collection of similar types of elements

we can declared array

Datatype arrayname[size];

In option(A) the size of array is 0 which is wrong thats why this option is wrong.

In option(B) the arrayname cannot start with ' $' thats why this option is wrong.

In option(c) we cannot give void datatype as a arrayname thats why this option is wrong.

So the correct option is(D) i.e int array[10];

User Lqc
by
5.6k points