Computer Science, asked by saiganesh2019243, 6 months ago

Create a class Reverse with one data member called num of type int and a static method find() to return reverse of num. Create another class ReverseR from Reverse which overrides method find() and this override method uses recursion to find and returns reverse of data member of its super class.

Answers

Answered by anjaliagnihotri2007
0

Answer:

(i) Take input the size of array and the elements of array.

(ii) Consider a function reverse which takes the parameters-the array(say arr) and the size of the array(say n).

(iii) Inside the function, a new array (with the array size of the first array, arr) is initialized. The array arr[] is iterated from the first element and each element of array arr[] is placed in the new array from the back, i.e, the new array is iterated from its last element.

(iv) In this way, all the elements of the array arr[] are placed reversely in the new array.

(v) Further, we can iterate through the new array from the beginning and print the elements of the array.

I hope it is helpful to you

Similar questions