Question: Which of the following statements are correct about the program below?
[A].The code is erroneous since the subscript for array used in for loop is in the range 1 to size.
The code is erroneous since the values of array are getting scanned through the loop.
The code is erroneous since the statement declaring array is invalid.
The code is correct and runs successfully.
[A].
[B].
[C].
[D].
Answer: Option C
Explanation:
The statement int arr[size]; produces an error, because we cannot initialize the size of array dynamically. Constant expression is required here.
Example: int arr[10];
One more point is there, that is, usually declaration is not allowed after calling any function in a current block of code. In the given program the declaration int arr[10]; is placed after a function call scanf().