Which Of The Following Errors Will Occur When The Below Code Is #2125
Which of the following errors will occur when the below code is executed?</p> <pre><code class="language-c"> #include<stdio.h> 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\n",ans); return 0; }</code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs122 Data Communication and Computer Network. It can also be found in gs gs122 Dynamic Programming - Catalan Number using Dynamic Programming - Quiz No.1.
Which of the following errors will occur when the below code is executed?
#include<stdio.h> 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\n",ans); return 0; }
Segmentation fault
Array size too large
Integer value out of range
Array index out of range
Similar question(s) are as followings:
Online Quizzes of gs122 Data Communication and Computer Network
Sorting - Insertion Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - Insertion Sort - Quiz No.2
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - Insertion Sort - Quiz No.3
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - LSD Radix Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - MSD Radix Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - MSD Radix Sort - Quiz No.2
gs gs122 Data Communication and Computer Network
Online Quizzes