Can we reverse a string wthout using STRING function?

All sort of Mainframes Interview Questions.
Post Reply
Alok Gandhi
New Member
Posts: 3
Joined: Thu Nov 20, 2014 11:25 am

Can we reverse a string wthout using STRING function?

Post 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 ... :(
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: Can we reverse a string wthout using STRING function?

Post 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.
User avatar
Angel
Registered Member
Posts: 95
Joined: Sat Jun 08, 2013 8:13 pm
India

Re: Can we reverse a string wthout using STRING function?

Post 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.
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: Can we reverse a string wthout using STRING function?

Post 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).
User avatar
Angel
Registered Member
Posts: 95
Joined: Sat Jun 08, 2013 8:13 pm
India

Re: Can we reverse a string wthout using STRING function?

Post by Angel »

That can also be correct. But I think Alok should have done some follow up with the interviewer for this question.
Post Reply

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

Register

Sign in

Return to “Interview Questions.”