Multiple choice c

float values(200) = ( 1 , 2 , 3 , 4 );

  1. is correct

  2. has syntax error

  3. causes run-time error

  4. none of the above

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

This line contains multiple syntax errors: parentheses are used instead of square brackets for array size, and braces are used instead of parentheses for the initialization list.

AI explanation

To answer this question, let's analyze the given code:

float values(200) = ( 1 , 2 , 3 , 4 );

This line of code is attempting to declare and initialize an array called values of type float with a size of 200. However, there is a syntax error in this code.

The correct syntax for declaring and initializing an array in C++ is as follows:

float values[] = {1, 2, 3, 4};

In this case, the size of the array is automatically determined based on the number of elements provided in the initializer list.

Therefore, option B) has a syntax error is the correct answer.

Option A) is incorrect because the code has a syntax error. Option C) is incorrect because the code does not execute to cause a run-time error. Option D) is incorrect because the correct answer is B) has syntax error.