Looping Statements Interview Questions
Perform Statement -
How do you use loops in COBOL?
Looping programming involves making a set of statements run in a repetitive, iterative, or looping manner. In looping programming, the statements execute repeatedly until the coded condition is true.
What are the looping statement?
PERFORM Statement
How do you use the perform statement in COBOL?
PERFORM statement executes the statement block repeatedly. The repetitive execution can be conditional or unconditional. If any condition is coded with it, the statements block gets executed until the coded condition is true.
Different types of perform statements?
PERFORM statement is mainly two types at high level based on how it is coded to perform the task –
- Inline PERFORM
- Outline PERFORM
What is PERFORM?
PERFORM statement executes the statement block repeatedly. The repetitive execution can be conditional or unconditional.
What is meant by an inline PERFORM?
PERFORM statement executes the statements block that is coded inline (between PERFORM and END-PERFORM).
What is the benefit of using inline perform in COBOL?
This requires no seperate paragraph or section.
What is the outline PERFORM?
PERFORM statement executes statements block that are coded outline (in a separate paragraph or section outside of PERFORM).
Explain the variation between inline and outline perform?
Inline PERFORM | Outline PERFORM |
---|---|
|
|
The PERFORM statement executes the statements block that is coded inline (between PERFORM and END-PERFORM) | The PERFORM statement executes statements block that are coded outline (in a separate paragraph or section outside of PERFORM). |
This requires no seperate paragraph or section. | It requires a separate paragraph or seection that needs to be coded with statements block. |
Not required to transfer the control to paragraph or section. | Control transfers to the paragraphs or sections |
Scope terminator END-PERFORM is mandatory | Scope terminator END-PERFORM is not required |
What is Simple PERFORM? How many types?
Simple PERFORM is a way to execute a given paragraph or section once, and control is passed to the next statement in the flow. It is both inline and outline.
What is PERFORM…THRU? How many types?
PERFORM...THRU statement is used to execute a specific paragraph or a range of paragraphs. It is outline PERFORM.
What is PERFORM…TIMES? How many types?
PERFORM...TIMES statement is used to execute a specific paragraph or section a certain number of times. It is both inline and outline.
What is PERFORM…UNTIL? How many types?
PERFORM...UNTIL statement is used to execute a statement block repetitively until a certain condition is true. It is both inline and outline.
What is PERFORM…VARYING? How many types?
PERFORM...VARYING is used to execute a specific paragraph or section repetitively while varying the value of one or more control variables.
How do you use the PERFORM WITH TEST BEFORE statement in COBOL, and what is its purpose?
It tests the condition before executing the statements block. It is default with PERFORM if not coded any.
What is the use of the PERFORM WITH TEST AFTER statement in COBOL?
It tests the condition after executing the statements block. Statements block gets executed once regardless of the condition truth value.
Which Search verb is equivalent to PERFORM...VARYING?
Simple SEARCH
What is the difference in PERFORM...UNTIL and PERFORM...VARYING?
PERFORM...UNTIL | PERFORM...VARYING |
---|---|
It is used to execute a statement block repetitively until a specific condition is TRUE. | It executes a specific paragraph or section repetitively while varying the values of the variables until the condition is satisfied. |
Variables used in this perform condition should be initialized, incremented, or decremented separately (outside of perform). | It handles the variable's initialization, increment, or decrement. |
Describe the distinction in COBOL between the PERFORM and CALL statements?
PERFORM | CALL |
---|---|
It is used to execute a statement block repetitively until a specific condition is TRUE. | It calls the sub program to complete the task. |
Statements block resides within the program. | Statements block is in the another program. |
Frequently Asked Questions -
What are various types of Perform in COBOL?
Explain the different types of perform in programming?
What are different ways of PERFORM, If you want to come out of it and you use GOTO how will be the execution?
What is an in-line PERFORM?
How in-line PERFORM can be coded?
What is an in line PERFORM? What is the use of it?
What is the use of the PERFORM VARYING statement in COBOL, and how can it be used to implement loops with variable counters?
How is PERFORM … WITH TEST AFTER different from PERFORM … WITH TEST BEFORE?
Which is the default, TEST BEFORE or TEST AFTER for a PERFORM statement?
When it comes to a PERFORM statement, which is the default—TEST BEFORE or TEST AFTER?
What is the difference between PERFORM ... WITH TEST AFTER and PERFORM ... WITH TEST BEFORE?
In a COBOL II PERFORM statement, when is the conditional tested, before or after the perform execution?
What is the difference between Perform With Test After and Perform With Test Before?
Explain the difference between PERFORM and CALL statements in COBOL. When would you use each, and what are the key considerations in choosing between them?
What search verb means PERFORM when it comes to varying?
What is the use of the PERFORM UNTIL statement in COBOL, and how is it different from the PERFORM VARYING statement?