If- else statement - cobol programming, COBOL Programming

Assignment Help:

IF ... ELSE STATEMENT:

We are familiar with an easy form of the IF statement. The common form of the IF statement is as shown below:

628_if else STATEMENT.png

Each of the statement-1 and statement-2 shows one or more COBOL statement. Whenever more than one statement is specified then they should be divided by one or more spaces or by an optional semicolon (;) or by comma (,). During execution, when the condition is found to be true, the statements presented by statement-1 are executed. On the other hand, when the condition is found to be false, the statements presented by statement-2 are executed. For ease of the reference, we shall call the statements represented by statement-1 and statement-2 as then part or else part respectively.

It may be noted that either the then Part or else part is executed depending on the value of the specified condition. Afterward, the control implicitly goes to the statement that instantly follows the IF sentence.

Generally, an If statement must be terminated by the period (.) followed by a blank. For this cause an IF statement is frequently referred to as an IF sentence. Many times, we encounter situations where no action requires to be specified if the condition is true, but some actions are essential if the condition is false. In that situation, the NEXT SENTENCE phrase can be used for the then part and the else part can be written to point the actions needed. Likewise, the NEXT SENTENCE phrase can substitute the else part if no action is needed when the condition is false. The NEXT SENTENCE phrase shows that the control should pass to the statement which follows the IF sentence. Note that if no action requires to be specified for the else part, the ELSE NEXT SENTENCE phrase being optional, can be absent.

Though, the phrase ELSE NEXT SENTENCE may not be omitted in many cases. The illustrations below describe the use of IF statement.


Related Discussions:- If- else statement - cobol programming

Move, can we move spaces to numeric field

can we move spaces to numeric field

Conditions-name condition, CONDITIONS-NAME CONDITION:   The condition...

CONDITIONS-NAME CONDITION:   The condition name is an entity which itself is a condition and these can have either a true or false value. Though, a condition name cannot be d

Negated simple condition, NEGATED SIMPLE CONDITION: Any of the easy co...

NEGATED SIMPLE CONDITION: Any of the easy condition explained can be preceded by the logical operator NOT. The consequence of placing the operator NOT before an easy condition

Edit characters for numeric data, Edit Characters for Numeric Data: Th...

Edit Characters for Numeric Data: The characters below can be used in the PICTURE clause to indicate the editing.   Z    *  $  -    +    CR    DB    .    ,    B    O    /

Example of read statement, Example of read statement: Illustration: ...

Example of read statement: Illustration: READ OLD-MASTER AT END MOVE ZERO TO END-OF-RECORDS. As a result of this statement, generally the next record from the OLD-MAST

If- else statement - cobol programming, IF ... ELSE STATEMENT: We are ...

IF ... ELSE STATEMENT: We are familiar with an easy form of the IF statement. The common form of the IF statement is as shown below: Each of the statement-1 and statem

Blank insertion and zero insertion, B (Blank Insertion) : The occurren...

B (Blank Insertion) : The occurrence of a B anyplace in the picture will insert a space character in the edited data. There can be more than one B in the picture. Examples:

Updating of the relative and indexed files, UPDATING OF THE RELATIVE AND IN...

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

Merge verb with output procedure, MERGE VERB WITH OUTPUT PROCEDURE: Li...

MERGE VERB WITH OUTPUT PROCEDURE: Like the sort verb, the merge verb can also have an output procedure. The syntax of the MERGE verb is as shown below:   The r

Close statement - sequential files, CLOSE statement: The simplified sy...

CLOSE statement: The simplified syntax of the CLOSE statement is as shown below:   CLOSE          file-name-1   [WITH   LOCK   ]                         [  , file-

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