Select the correct option to test your answer:
More Computer Questions
Which is not a box-level element?
What is the purpose of polymorphism in Ruby?
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { char* ptr; unsigned long int a = (size_t(0) / 3); cout << a << endl; try { ptr = new char[size_t(0) / 3]; delete[ ] ptr; } catch(bad_alloc &thebadallocation) { cout << thebadallocation.what() << endl; }; return 0; }
Which are the advantages of functions in python?
What will be the output of the following code? #include <bits/stdc++.h> using namespace std; void func(int arr[], int n) { int count[n]; memset(count, 0, sizeof(count)); for (int i=n-2; i>=0; i--) { if (arr[i] >= n - i - 1) count[i]++; for (int j=i+1; j < n-1 && j <= arr[i] + i; j++) if (count[j] != -1) count[i] += count[j]; if (count[i] == 0) count[i] = -1; } for (int i=0; i<n; i++) cout << count[i] << " "; } int main() { int arr[] = {1, 3, 5, 8, 9}; int n = sizeof(arr) / sizeof(arr[0]); func(arr, n); return 0; }