Count SPACE character without INSPECT and STRING in COBOL?

All sort of Mainframes Interview Questions.
Post Reply
Shahid
Registered Member
Posts: 47
Joined: Sun Aug 25, 2013 1:00 am

Count SPACE character without INSPECT and STRING in COBOL?

Post by Shahid »

Hi

Count SPACE character without INSPECT and STRING in COBOL?

In one of the interview I was asked that how to count the space characters in particular variable (15 characters) without using INSPECT and STRING?

My answer was to use PERFORM and use Reference Modification but it was not correct, can someone please answer what can be correct answer for it?
User avatar
Anuj Dhawan
Founder
Posts: 2799
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: Count SPACE character without INSPECT and STRING in COBOL?

Post by Anuj Dhawan »

May be redefine the variable with OCCURS 15 times of one byte each. PERFORM varying with a counter should get what you've asked for. :?
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1885
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Count SPACE character without INSPECT and STRING in COBOL?

Post by Robert Sample »

can someone please answer what can be correct answer for it?
Why not ask the interviewer? There are at least 3 possible ways to do this:
1. INSPECT
2. Reference modification
3. REDEFINES as an array and iterate across the array.

All of them are viable solutions -- but only the interviewer could tell you what their "correct" solution is.
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.”