Page 1 of 1
Can we reverse a string wthout using STRING function?
Posted: Thu Nov 20, 2014 12:07 pm
by Alok Gandhi
Hi,
I was asked this : How can we reverse a string wthout using STRING function? If I have it like "Alok Gandhi" the output should be - "ihdnaG kolA". I had no clue about the answer ...

Re: Can we reverse a string wthout using STRING function?
Posted: Thu Nov 20, 2014 1:07 pm
by William Collins
Let me first ask a question back. How would you reverse a field using STRING? It is possible, but I doubt that you are the asker can do it other than hardcoding it. And it is not a function. If you had looked at the FUNCTIONs, you may have found your first answer.
Re: Can we reverse a string wthout using STRING function?
Posted: Thu Nov 20, 2014 2:08 pm
by Angel
I think it's a trick question and interviewer wanted to enquire if you know that the question itself is not that correctly worded. Perhaps he wanted to know that you interrupt in between and say reference modification might do it.
Re: Can we reverse a string wthout using STRING function?
Posted: Thu Nov 20, 2014 3:03 pm
by William Collins
FUNCTION REVERSE is probably the answer expected.
Loads of other ways to do it (FUNCTION has only been in COBOL since 1989).
Re: Can we reverse a string wthout using STRING function?
Posted: Mon Dec 01, 2014 11:48 am
by Angel
That can also be correct. But I think Alok should have done some follow up with the interviewer for this question.