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
Rules for apply for the condition name: The rules below apply for the condition name. (i) The Condition names should be explained at level 88. The level number starts in ma

THE SIMPLE SORT VERB: The process of sequencing the records in some preferred manner is termed as sorting. The Sorting is done upon some key data item in the record. For illus

Sign - Picture clause: The numeric data item can be signed or unsigned. If a numeric data is regarded as unsigned then during the execution these unsigned data items are treat

Program for Sequential File Creation & Rewriting  We have to write a program to create a Length file with just two fields: l (Length) and l-c (Length-Code). Add a few records.

Group Item as Operand in the Relational Condition: Whenever an operand of a relational condition is the group item, the item is then considered to be an alphanumeric field. Th

Illustration of Perform with varying option: A) Perform para-3 varying the k from 1 by 1 until k > 10. Here para-3 will be constantly executed 10 times (For k=1,2,3, .....1

SIMPLE MERGE VERB: Like sorting, the merging of files is often required in different commercial application. It is likely to merge two or more files with the help of one MERGE

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

BLOCK CONTAINS CLAUSE: Integer -1 of the BLOCK CONTAINS clause indicates the block size either in terms of records or in terms of characters. For illustration, BLOCK CONTAINS

FILE CHARACTERISTICS: The task of file handling is the responsibility of the system software termed as IOCS (Input-Output control system). Record Size: We know that th