Conditional Statements Interview Questions


What is a conditional statement in COBOL?

A conditional statement derives a condition's truth value (TRUE or FALSE), and decides the further program execution flow.

What are the conditional statements in COBOL?

The conditional statements are -

  • IF Statement
  • EVALUATE Statement
  • Statements with conditional phrases

IF Statement -

What is significance of IF statement?

IF statement validates a condition to get the truth value and executes the statements under IF when the condition is TRUE.

What are the different IF statements?

IF statements are of three types based on their usage in the program -

  • Simple IF
  • IF...ELSE
  • Nested IF

Evaluate Verb -

What is the use of EVALUATE statement?

EVALUATE validates multiple conditions at a time and controls the program flow. It is a shorter form for the nested IF...ELSE and simplifies the logic when multiple choices are available.

What are the types of EVALUATE statement?

EVALUATE can be divided logically into the below types based on their usage in the program -

  • Simple EVALUATE
  • EVALUATE TRUE
  • EVALUATE with THRU
  • EVALUATE with grouping multiple WHEN conditions
  • EVALUATE...WHEN with combined conditions

In an EVALUTE statement is the order of the WHEN clauses significant?

Yes

Conditional Expressions -

CLASS condition -

What is the significance of CLASS condition?

CLASS condition tests whether the data in a variable belongs to a specific category of data.

Relation condition -

What is the significance of RELATION condition?

A relation condition compares two operands using relational operators (=, >, <, <=, >=, <>) and returns a boolean value of TRUE or FALSE.

Sign condition -

What is the significance of SIGN condition?

SIGN condition tests the sign (positive, negative, or zero) of the data in numeric variables.

Combined condition -

What is the combined condition?

A combined condition is a logical group with two or more conditions.

Negated Condition -

What is the negated condition?

A condition is negated with the use of the logical operator NOT.

Statements used with IF & EVALUATE -

CONTINUE -

Explain the CONTINUE statement in COBOL?

CONTINUE statement transfers the control to the immediate COBOL statement that comes next in the program flow.

NEXT SENTENCE -

Explain the NEXT SENTENCE statement in COBOL?

NEXT SENTENCE transfers the control to the following COBOL statement immediately after the explicit scope terminator (period - '.') in the flow.

Frequently Asked Questions -

Explain the objective of using conditional statements in programming?

How to compare if, else, and evaluate statements?

Explain the use of EVALUATE statement?
How do you use the evaluate statement in COBOL?

What procedure do you follow to come out of an EVALUATE statement?

What are common forms of evaluate statements?
How do you use the EVALUATE statement in COBOL, and what are the different types of conditions that can be evaluated?

How to code negated condition in the COBOL program?

What are the other statements come up with CONTINUE statement in COBOL?

What are the other statements come up with NEXT SENTENCE statement in COBOL?