Illustration of nested if statement, COBOL Programming

Illustration of nested if statement:

Consider the nested sentence which is as shown below:

1186_Illustration of nested if statement.png

The IF-ELSE pairs in this sentence can be detected by applying the rule which is stated above. We point out the IF-ELSE relations by marking each pair with similar numbers within the circle. The sentence can now be easily acknowledged as an implementation of the following flow chart.

 

511_Illustration of nested if statement1.png

It can also be seen that while the last ELSE NEXT SENTENCE phrase can be dropped, it is not possible to drop the initial ELSE NEXT SENTENCE phrase. If this initial phrase is absent, the pairing of IF's and ELSE's will be disturbed. It is left as an exercise to confirm that the BONUS-CODE will then remain unchanged if the STAFF-CODE is other than the 1.

Though the similar action will be taken when STAFF-CODE is equal to 1, it is worthwhile to examine that this is as the condition in the last IF statement can never be true.

And hence, we examine the ELSE NEXT SENTENCE phrase is useful in many cases. The phrase also increases the readability. And hence, the use of the NEXT SENTENCE either in the then or else parts of an IF statement is suggested. The only exception can be when the

ELSE NEXT SENTENCE phrase is instantly followed by the terminating period of the IF sentence. This is because in this situation the ELSE should apply to the IF of the most inclusive IF statement of the nesting. And hence, the control will be transferred to the next sentence regardless of whether or not the ELSE NEXT SENTENCE phrase is explicitly involved.

Posted Date: 10/17/2012 2:07:53 AM | Location : United States







Related Discussions:- Illustration of nested if statement, Assignment Help, Ask Question on Illustration of nested if statement, Get Answer, Expert's Help, Illustration of nested if statement Discussions

Write discussion on Illustration of nested if statement
Your posts are moderated
Related Questions
Illustration of Subtract verb: (a) SUBTRACT A FROM B. This illustration means that the value of A will be subtracted from the value of B and the subtracted result will be s

FILE DESCRIPTION- FIXED-LENGTH RECORDS: The normal characteristics of a file are explained in the file description (FD) entry of the DATA DIVISION.

Example of Open statement: Illustration: The OPEN INPUT TRANSACTION, OLD-MASTER OUTPUT NEW-MASTER. The illustration represents that there are two input files named the

RULES FOR OCCURS CLAUSE: The rules apply for the OCCURS clause and the subscripts are as shown below. (1) The integer in the OCCURS clause should be a positive integer.

SEQUENTIAL FILE CREATION AND REWRITING: We have to write a program to create a student file with just two fields: sno i.e. Student Number and same i.e. Student Name. Add a few

PROGRAM FOR PERFORM ...UNTIL We have to write a program to find the sum of "n" natural numbers. Identification division. Program- id. PerfUntil. Environment division.

NONSTANDARD CLAUSES: The various clauses explained above are as per the ANSI standard. Also, most compilers provide for additional nonstandard clauses to meet the specific nec

Example of condition names: The illustration below is of the use of the condition names  77  MARITAL-STATUS     PIC    9   88  SINGLE    VALUE    IS     ZERO   88  MA

PROGRAM FOR ADD VERB: We have to write a simple program to elaborate the ADD verb. You can also use edit characters in the program. Identification division. Program- id.

UPDATING OF THE RELATIVE AND INDEXED FILES: The Sequential files are updated by creating a new master file from an existing old master file and a transaction file. Such an Upda