Select the correct option to test your answer:
Computer
Miscellaneous On Data Structures
Difficulty: Medium
What is the output of the following code? #include<iostream> using namespace std; void printArray(int p[], int n) { for (int i = 0; i <= n-1; i++) cout << p[i] << " "; cout << endl; } void func1(int n) { int p[n]; int k = 0; p[k] = n; while (true) { printArray(p, k+1); int rem_val = 0; while (k >= 0 && p[k] == 1) { rem_val += p[k]; k--; } if (k < 0) return; p[k]--; rem_val++; while (rem_val > p[k]) { p[k+1] = p[k]; rem_val = rem_val - p[k]; k++; } p[k+1] = rem_val; k++; } } int main() { int n=3; func1(n); return 0; }
More Computer Questions
How many edges does a n vertex triangle free graph contains?
A sequence of instructions, in a computer language, to get the desired result, is known as
How can you create a custom exception class in Python?
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A { float d; public: A(){ cout<<"Constructor of class A\n"; } }; class B: public A { int a = 15; public: B(){ cout<<"Constructor of class B\n"; } }; int main(int argc, char const *argv[]) { B b; return 0; }
What will be the output of the following Python code? class Truth: pass x=Truth() bool(x)