View previous topic :: View next topic
|
Author |
Message |
arindambanerjee
New User
Joined: 30 Jun 2007 Posts: 39 Location: India
|
|
|
|
Hi,
I have been asked a question in an interview as below:
CASE1:
....
A0-section.
......
Perform AB-para.
...
...
A0-Exit
Exit.
AB-Para.
...
...
Perform D-para.
....
AB-para-end.
exit.
CASE2:
...
A0-section.
......
Perform AB-para thru AB-para-end.
...
...
A0-Exit
Exit.
AB-Para.
...
...
Perform D-para.
....
AB-para-end.
exit.
D-Para is there in the code as well.
the question was whats the difference between these two cases and if there is no difference then what will be the flow. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Have you reviewed the COBOL Language Reference (manuals link at the top of the page) on the PERFORM statement?
PERFORM paragraph performs only that paragraph. So case 1 would execute the PERFORM, then A8-Para, then D-para, then at the end of A8-Para would return to A0-section and continue. If there's no program exit, control would fall through A0-Exit and start executing A8-Para and so forth.
The main difference in case 2 in that execution would go through the end paragraph, but otherwise there's no difference in execution sequence. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
There is no difference in both the approaches from execution per se as Robert has said; though at some shops coding "..thru AB-para-end" in "Perform AB-para thru AB-para-end" comes under coding standards. Every PARA should end with an EXIT though period (.) in place of EXIT would also do the same. |
|
Back to top |
|
|
|