The following functions are part of some class
i) What will be the output of fun1() when the value of s[] ={‘J’,’U’,’N’,’E’} AND X= 1?
ii) What will be the output of fun2() when the value of n =”SCROLL” ?
iii) State in one line what does the function fun1() do apart from recursion
void fun1(char s[], int x)
{
System.out.println(s);
char temp;
if(x<s.length/2)
{
temp=s[x];
s[x] = s[s.length-x-1];
s[s.length-x-1]=temp;
fun1(s, x+1);
}
}
void fun2(String n)
{
char c[]=new char[n.length()];
for(int i=0;i<c.length; i++)
c[i]=n.charAt(i);
fun1(c,0);
}
i)
JUNE
JNUE
ii)
SCROLL
LCROLS
LLROCS
LLORCS
iii)
Reverses the part of a string from a specified location