Illustration of nested if statement, COBOL Programming

Assignment Help:

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.


Related Discussions:- Illustration of nested if statement

Nested if statement, NESTED IF STATEMENT:   The then and else stateme...

NESTED IF STATEMENT:   The then and else statement of an IF statement can hold other IF statements. The involved IF statements in their turn may also hold other IF statements

Rules for indexed tables, RULES FOR INDEXED TABLES: The rules of index...

RULES FOR INDEXED TABLES: The rules of indexing a table with an INDEXED phrase are as shown below: (1) If indexing is completed for any one level of a table, then indexing

File characteristics, FILE CHARACTERISTICS: The task of file handling ...

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

Data names and identifiers - cobol program, Data Names and Identifiers:   ...

Data Names and Identifiers:   The Data name provides reference to the storage space in the memory where the real value is stored. This value takes part in the operation whene

Program using occurs clause, PROGRAM USING OCCURS CLAUSE: We have to w...

PROGRAM USING OCCURS CLAUSE: We have to write a simple program to demonstrate Occurs Clause. Get the employee details for 3 persons and compute the total salary. identifica

Perform statement, PERFORM STATEMENT:   The PERFORM statement can be ...

PERFORM STATEMENT:   The PERFORM statement can be used to execute the group of consecutive statements written elsewhere in the program. We refer to this group of statements a

Illustration of perform statement, Illustration of perform statement: ...

Illustration of perform statement: PERFORM    CALCUALTE-TAX. In this illustration, the CALCULATE-TAX is either a section name or paragraph name. Assume that it is a section

Relational condition - cobol programming, RELATIONAL CONDITION:   We ...

RELATIONAL CONDITION:   We know that a relational condition specifies a comparison between two operands and has the form.     Operand-1    relational-operator   operand-2

Program for indexed sequential file creation-mode, PROGRAM FOR INDEXED SEQU...

PROGRAM FOR INDEXED SEQUENTIAL FILE CREATION (RANDOM MODE): We have to write a program to create an Indexed Sequential File in random mode for Student particulars. Suppose jus

File volatility and file interrogation, File volatility: File volatili...

File volatility: File volatility associates to the number of times the updating of records are needed during some time period. File interrogation: Some files hold re

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd