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 ...
Can we reverse a string wthout using STRING function?
-
- New Member
- Posts: 3
- Joined: Thu Nov 20, 2014 11:25 am
-
- Global Moderator
- Posts: 490
- Joined: Sun Aug 25, 2013 7:24 pm
Re: Can we reverse a string wthout using STRING function?
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?
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.
-
- Global Moderator
- Posts: 490
- Joined: Sun Aug 25, 2013 7:24 pm
Re: Can we reverse a string wthout using STRING function?
FUNCTION REVERSE is probably the answer expected.
Loads of other ways to do it (FUNCTION has only been in COBOL since 1989).
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?
That can also be correct. But I think Alok should have done some follow up with the interviewer for this question.
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute