Question 4 Analyze the following two programs: Program A: void aFunc(int length) { if (length > 1) ( int main() { aFunc
Posted: Sun Jul 03, 2022 12:00 pm
Question 4 Analyze the following two programs: Program A: void aFunc(int length) { if (length > 1) ( int main() { aFunc (5); Program B: public static void bFune (int length) { while (length > 1) { cout << (length - 1) << " "; bFunc (length (1); cout << (length - 1) << " "; aFunc (length - 1); } 1 int main() { bFunc (5); O The two programs produce the same output 5 4 321. Program A produces the output 4 3 2 1 and Program B prints 4 3 2 1 1 1 1 infinitely. The two programs produce the same output 4 32 1. O The two programs produce the same output 1234. The two programs produce the same output 1 2 3 4 5.
Question 2 What does the following code display? void foo (int x[], int len) ( cout << x [len - 1] << " "; fqo (x, len - 1); int main() { } int x[] = {1, 2, 3, 4); foo (x, 4); O The program displays 1 2 3 4. O The program displays 4 3 2 1 and then the index will be out of bounds. O The program displays 4 3 2 1. O The program displays 1 2 3 4 and then the index will be out of bounds. O The program displays 4.
Question 2 What does the following code display? void foo (int x[], int len) ( cout << x [len - 1] << " "; fqo (x, len - 1); int main() { } int x[] = {1, 2, 3, 4); foo (x, 4); O The program displays 1 2 3 4. O The program displays 4 3 2 1 and then the index will be out of bounds. O The program displays 4 3 2 1. O The program displays 1 2 3 4 and then the index will be out of bounds. O The program displays 4.