Choose the correct definition of a numeric field.

All sort of Mainframes Interview Questions.
Post Reply
SuperRa
New Member
Posts: 5
Joined: Thu Dec 04, 2014 2:22 pm

Choose the correct definition of a numeric field.

Post by SuperRa »

Hi,

The interviewer wrote this on paper

Code: Select all

05 WS-VARIABLE1 PIC S9(05)V99.
and

Code: Select all

05 WS-VARIABLE2 PIC +99999.99.
and said that I want to move +12345.67 in any of these variables. I have two choices, one I want to use the variable in the program. May be I shall use the variable for calculation and I may not. For other choice, I want to and display it I want to use the variable in the program. May be I shall use the variable for calculation and I may not but at the end of the program I want to display the variable in this choice.

Which one of the above is the correct way to define for this?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Choose the correct definition of a numeric field.

Post by Robert Sample »

WS-VARIABLE1 is a numeric variable and can be used as such in COBOL. WS-VARIABLE2 is a numeric edited variable -- which is NOT a numeric variable -- and COBOL limits what you can do with it. Numeric edited variables are used most often to display data (in a report, often).
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: Choose the correct definition of a numeric field.

Post by William Collins »

To get directly-human-readable (non-programmer) output and do calculation, you could do with using both.

A numeric-edited field cannot be used in calculations, but is the best way to represent output.

A numeric field can be used in calculation, but, especially when signed and having decimal places, is not easy for a non-technical person to understand.
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.”