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?
Count SPACE character without INSPECT and STRING in COBOL?
- Anuj Dhawan
- Founder
- Posts: 2812
- Joined: Sun Apr 21, 2013 7:40 pm
- Location: Mumbai, India
- Contact:
Re: Count SPACE character without INSPECT and STRING in COBOL?
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.
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.
- Robert Sample
- Global Moderator
- Posts: 1899
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: Count SPACE character without INSPECT and STRING in COBOL?
Why not ask the interviewer? There are at least 3 possible ways to do this:can someone please answer what can be correct answer for it?
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.
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