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

Picture specification - picture clause, PICTURE specification: The siz...

PICTURE specification: The size of a group item is equivalent to the total of the sizes of all the subordinate elementary items. The group item class is alphanumeric. The i

Program to demonstrate sort verb, PROGRAM TO DEMONSTRATE SORT VERB: Th...

PROGRAM TO DEMONSTRATE SORT VERB: The file for which a record having 2 fields, viz., Account Number and Name is already available. Sort the file based on the ascending order o

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

Block size - file characteristics , Block Size: The normal practice is...

Block Size: The normal practice is to group a number of consecutive records to form that is termed as a block or a physical record. The number of records in a block is frequen

Column and field in cobol program, Column and Field in COBOL program: ...

Column and Field in COBOL program: In COBOL there are 2 types of entries termed as margin A and margin B entries. The Margin A entries start from the column 8, 9, 10 or 11 and

Occurs clause - program, OCCURS CLAUSE - PROGRAM: We have to write a p...

OCCURS CLAUSE - PROGRAM: We have to write a program to demonstrate the occurs clause. Get names of the students and show them on the screen.  identification division.

Indexed tables, INDEXED TABLES: The OCCURS clause that is used to defi...

INDEXED TABLES: The OCCURS clause that is used to define tables can optionally have an INDEXED phrase. This phrase involves the names of data items which are to be used as sub

Rules for simple sort verb, Rules for Simple sort verb: The work file ...

Rules for Simple sort verb: The work file is to be defined by a sort elaboration entry (SD entry).The format of SD entry is as shown below. The rules below should be taken

Abbreviation of compound condition, Abbreviation: The Consecutive rela...

Abbreviation: The Consecutive relational conditions in a compound condition can be abbreviated in many cases as shown: (i) When the subjects in the consecutive relational c

Different data types available in cobol, Data types available in COBOL are ...

Data types available in COBOL are given below Alpha-numeric (X), numeric (9), alphabetic (A)

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