What is the output generated by the following code?
01 GRP-I.
05 SUBFLD1 PIC XX VALUE "AB".
05 FILTER PIC X(6) VALUE SPACES.
01 GRP-2 REDEFINED GRP-1.
05 SUB-FLD2 PIC XX.
05 SUB-FLD3 PIC XX.
05 FILTER PIC X(4).
IF SUB-FLD1 NOT = SPACES
DISPLAY "SUBFLD1"
MOVE "ABBCCD" TO GRP-1
IF SUB-FLD3 = SPACES
DISPLAY "SPACES"
ELSE
DISPLAY "SUBFLD3"
DISPLAY "END"
ELSE
DISPLAY "SPACES"
DISPLAY "END".
(a) SUBFLD1
SUBFLD3
END
(b) SPACES
END
(c) SUBFLD1
END
(d) SUBFLD1
SPACES
Answers were Sorted based on User's Feedback
Answer / vish
I doubt if we can code like IF ELSE ELSE....since no scope
terminatior (END-IF) has been given for the nested IF ELSE
so it should throw a compilation error. It can display the
output as (a) ONLY if the code is something like below:
01 GRP-1.
05 SUBFLD1 PIC XX VALUE "AB".
05 FILTER PIC X(6) VALUE SPACES.
01 GRP-2 REDEFINED GRP-1.
05 SUB-FLD2 PIC XX.
05 SUB-FLD3 PIC XX.
05 FILTER PIC X(4).
IF SUB-FLD1 NOT = SPACES
DISPLAY "SUBFLD1"
MOVE "ABBCCD" TO GRP-1
IF SUB-FLD3 = SPACES
DISPLAY "SPACES"
ELSE
DISPLAY "SUBFLD3"
DISPLAY "END"
END-IF
ELSE
DISPLAY "SPACES"
DISPLAY "END".
Please correct me if I am wrong.
| Is This Answer Correct ? | 5 Yes | 1 No |
Answer / vish
Uttam, I guess you missed to see the REDEFINES part of the
code given. It's moving 'ABBCCD' to GRP-1 and since GRP-2
REDEFINES GRP-1, the variables in GRP-2 also will be
populated and then naturally SUB-FLD3 is not SPACES and
contain 'BC'. So the correct answer is (a).
I request - please don't be in hurry to answer the
questions. A lot many people build their concepts based on
the questions & queswers provided in such groups.
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / guest
I hope SUBFLD1 is erroneously written as SUB-FLD1
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / muttaiah
I guess we will get Maxcc - 8 when we compile. Because
SUB-FLD1 is not declared anywhere here. If the field has to
be SUBFLD1 by typo mistake.
Then answer would be (a).
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / uttam das
my answer is (d)
SUB-FLD3 = SPACES, it satisfies bcz in grp-2
there is no initialization of sub-fld3.
when sub-fld3 is not initialize, it always contains spaces.
alphanumeric stored spaces and numeric stored zeros
| Is This Answer Correct ? | 0 Yes | 5 No |
can I copy book which contain db2 statment in procedure divion?
I have a program with an Array of 5000 occurences which is being passed from 5 sub levels to the front end screen. Thess 5 programs using each 5*2 = 10 different arrays with size as 5000. This is causing the transaction to utilize more storage consupmtion. I am looking to reduce the storage consumption. As part of that initially i thought Dynamic array may solve my problem. After viewing the comments given i see its same as normal array. IS there any other way we can resolve this issue?
what is the default print format? in cobol
What care has to be taken to force program to execute above 16 Meg line?
In COBOL, what is the different between index and subscript?
0 Answers TryTechnicals Pvt Ltd,
How did the release of cobol/370 version 1.3 improve the performance of release 1.1?
I need to compare 3 variables(dates) and do some processing based on the earliest date. There could be more then 1 date record in any of the 3 fields. What is the best way to code this?
C1 C2 C3 are three conditions whose TRUTH values are as folloes. C1-TRUE C2-FALSE C3-TRUE A,B,C are defined as given below A:C1 AND(NOT C2) OR C3 B.(NOT C1) OR (NOT C2 AND NOT C3) C.(C1 OR C2)AND C3 D.C1 AND C2 OR C3 given the above information which of the following statements are valid? a.only A,B and C are TRUE b.only A,C and D are TRUE c.A,B,C and D are TRUE d.only C and D are TRUE
How to get the last record in vsam file in cluster? And how can you get the kids file records into your cobol program?
Give some examples of command terminators?
what is sysncpoint?
ZEROES and SPACES are _______ constants (a) Figurative (b) Numeric (c) Non-numeric (d) Alphabete