Solve this problem with recursion | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Solve this problem with recursion

Suppose you are given an array A, which has n elements. Write a recursive function to print that array in the following order. A[0] A[n-1] A[1] A[n-2] A[3] A[n-3] ......... ......... A[(n-1)/2] A[n/2], Where n >=2. Input : 5 1 5 7 8 9 Output: 1 9 5 8 7 7 ***How can I use local variable in the recursive function? Is it possible to use without initialize in every iteration?

14th Dec 2022, 3:54 AM
KAZI FAISAL MAHMUD
KAZI FAISAL MAHMUD - avatar
2 Answers
0
I'm not solving the problem. Just answering the last part. If you want to use the variable in each recursion use static variable.
14th Dec 2022, 6:04 AM
Kashyap Kumar
Kashyap Kumar - avatar
0
Remember that, for your learning process, you should solve the problem, with the help you can get, not anyone else.
14th Dec 2022, 11:15 PM
Emerson Prado
Emerson Prado - avatar