What Will Be The Output For The Following Codep Pre Langc #293

What will be the output for the following code?</p> <pre><code class="language-c"> #include <stdio.h> bool func(int arr[], int n, int sum) { bool subarr[n+1][sum+1]; for (int i = 0; i <= n; i++) subarr[i][0] = true; for (int i = 1; i <= sum; i++) subarr[0][i] = false; for (int i = 1; i <= n; i++) { for (int j = 1; j <= sum; j++) { if(j<arr[i-1]) subarr[i][j] = subarr[i-1][j]; if (j >= arr[i-1]) subarr[i][j] = subarr[i-1][j] || subarr[i - 1][j-arr[i-1]]; } } return subarr[n][sum]; } int main() { int arr[] = {3, 3, 4, 4, 7}; int sum = 5; int n = sizeof(arr)/sizeof(arr[0]); if (func(arr, n, sum) == true) printf("true"); else printf("false"); return 0; } </code></pre>

Online Quiz 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 Checksum Complexity Classes and NP-Complete Problems - Subset Sum Problem - Quiz No.1.


Similar question(s) are as followings:



Online Quizzes of gs122 Data Communication and Computer Network

Choose an organization

Theme Customizer

Gaussian Texture



Gradient Background