Which of the following statements are correct about the program below?
#include void main() { int size, i; scanf("%d", &size); int arr[size]; for(i=1; i<=size; i++) { scanf("%d", arr[i]); printf("%d", arr[i]); } }
A.The code is erroneous since the statement declaring array is invalid.
B.The code is erroneous since the subscript for array used in for loop is in the range 1 to size.
C.The code is correct and runs successfully.
D.The code is erroneous since the values of array are getting scanned through the loop.
Answers
Answered by
3
Hii dear here is your answer
option a is the correct answer
Hope it's help u
option a is the correct answer
Hope it's help u
Answered by
0
Answer:
The code is erroneous since the statement declaring array is invalid.
Explanation:
- Consider the statement int arr[size] . in this declaration of array arr the size of the array is size which is a variable and its value will be given by the user during runtime.
- scanf("%d", &size); statement will take the value of size variable from user during runtime.
- During the compilation of the given program, the compiler will through an error for int arr[size] as the value of size is not defined.
Similar questions
Math,
7 months ago
English,
7 months ago
Computer Science,
1 year ago
Computer Science,
1 year ago
English,
1 year ago
Math,
1 year ago
Math,
1 year ago