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

Currency sign - edit characters for numeric data, Currency Sign - edit char...

Currency Sign - edit characters for numeric data: $ (Currency Sign): The single currency sign can appear at the leftmost place of a picture. In that situation the $ cha

Multiply verb, MULTIPLY VERB:   The Multiply Verb causes one or more ...

MULTIPLY VERB:   The Multiply Verb causes one or more multiplicands to be multiplied by the multiplier and to store the products. The form of the MULTIPLY verb is as shown be

Evaluate statemant, single program how may when statement has used

single program how may when statement has used

Rounded option, ROUNDED OPTION: Let us consider the DATA DIVISION entr...

ROUNDED OPTION: Let us consider the DATA DIVISION entries which are as shown below: Now, subsequent to the execution of the statement ADD A B GIVING C, the C will hold

Object-computer - configuration section, Object-Computer - Configuration se...

Object-Computer - Configuration section: The computer name specifies a specific computer on which the object program is to be executed. The MEMORY SIZE is used to show the

Direct organization, Direct Organization: Besides the relative or inde...

Direct Organization: Besides the relative or indexed organization, also a direct access file can be designed to have what is termed as direct organization.  In this organizati

Delete statement - indexed files, DELETE STATEMENT : The file should be...

DELETE STATEMENT : The file should be opened in the I-O mode. If the access is SEQUENTIAL, the INVALID KEY phrase must be specified. Rather than, the last input-output state

Program for renames clause, PROGRAM FOR RENAMES CLAUSE: identification...

PROGRAM FOR RENAMES CLAUSE: identification division. program- id. environment division. data division. working-storage section. 01 emp.      02 empdet.

File-control paragraph for the relative files, FILE-CONTROL paragraph for t...

FILE-CONTROL paragraph for the relative files: The normal format for the SELECT clause for a relative file is as shown below. SELECT  file-name  ASSIGN  TO  implementor-nam

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