Vidyalelo
Data Structure · Q117

Dynamic Programming in Data Structures

Programming · Data Structure · question 117

Q117

Which of the following errors will occur when the below code is executed? #include int cat_number(int n) int i,j,arr[n],k; arr[0] = 1; for(i = 1; i < n; i++) arr[i] = 0; for(j = 0,k = i - 1; j < i; j++,k--) arr[i] += arr[j] * arr[k]; return arr[n-1]; int main() int ans, n = 100; ans = cat_number(n); printf("%d ",ans); return 0;

A.
Segmentation fault
B.
Array size too large
C.
Integer value out of range
Answer
D.
Array index out of range

Answer: Option C

Solution

Answer: Option C
No explanation is given for this question Let's Discuss on Board