Vidyalelo
Data Structure · Q946

Miscellaneous on Data Structures

Programming · Data Structure · question 946

Q946

What will be the output for the following code? #include bool func(int arr[], int n, int sum) if (sum == 0) return true; if (n == 0 && sum != 0) return false; if (arr[n-1] > sum) return func(arr, n-1, sum); return func(arr, n-1, sum) || func(arr, n-1, sum-arr[n-1]); int main() int arr[] = 4,6, 12, 2; int sum = 12; int n = sizeof(arr)/sizeof(arr[0]); if (func(arr, n, sum) == true) printf("true"); else printf("false"); return 0;

A.
12
B.
4 6 2
C.
True
Answer
D.
False

Answer: Option C

Solution

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