Page 1 of 1
COBOL interview question on PERFORM VARYING.
Posted: Mon Jun 19, 2023 12:05 pm
by utkarsh
Hi,
Please guide on this interview question, What is the content of RESULT after execution of the following COBOL instruction. The start value of RESULT is 0.
Code: Select all
PERFORM VARYING C FROM 1 BY 1 UNTIL C = 6
ADD 1 TO RESULT
END-PERFORM
Re: COBOL interview question on PERFORM VARYING.
Posted: Tue Jun 20, 2023 10:07 pm
by Robert Sample
Code is
Code: Select all
77 C PIC 9(04) COMP.
77 RESULT PIC 9(04).
PROCEDURE DIVISION.
000-START.
PERFORM VARYING C FROM 1 BY 1 UNTIL C = 6
ADD 1 TO RESULT
END-PERFORM.
DISPLAY 'C= ' C ' RESULT= ' RESULT.
with results of
The test is performed before the execution of the loop and hence these results.
Re: COBOL interview question on PERFORM VARYING.
Posted: Fri Jun 30, 2023 2:27 pm
by utkarsh
Thank you for your detailed explnation, really helpful.
Is it possible to test such cases on personal computer as these days I am on bench and don't have mainframe access.
Re: COBOL interview question on PERFORM VARYING.
Posted: Sun Jul 02, 2023 6:41 am
by Robert Sample
Yes. GnuCOBOL is available to download for various platforms including Windows and Linux. GnuCOBOL has standard COBOL support, and I've run mainframe (Enterprise COBOL) program on it with no issues.
Re: COBOL interview question on PERFORM VARYING.
Posted: Thu Aug 03, 2023 1:28 pm
by utkarsh
Thanks Robert. I tried downloaded GnuCOBOL, installing it and I can not make it work. Instructions are not very clear. Could you or someone guide on how to install GnuCOBOL on laptop?