If- else statement - cobol programming, COBOL Programming

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.

Posted Date: 10/17/2012 1:53:21 AM | Location : United States







Related Discussions:- If- else statement - cobol programming, Assignment Help, Ask Question on If- else statement - cobol programming, Get Answer, Expert's Help, If- else statement - cobol programming Discussions

Write discussion on If- else statement - cobol programming
Your posts are moderated
Related Questions
Occurs Clause: Let us establish tables with the help of an illustration. Assume that there are ten different types of income-tax rates that are read from some input medium and

Picture Clause: The picture clause explains the general characteristics of an elementary data item. These characteristics are elaborated below: Class: In COBOL the

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

FILE DESCRIPTION- FIXED-LENGTH RECORDS: The normal characteristics of a file are explained in the file description (FD) entry of the DATA DIVISION.

What is the difference between subscript and index

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

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

SUBTRACT VERB: The SUBTRACT verb is used to subtract one, or the sum of two or more numbers from one or more numbers and to store the result. The form of the SUBTRACT verb

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

PROGRAM FOR PERFORM - VARYING: We have to write a program to elaborate PERFORM ...VARYING Identification division. Program- id. PerfVary. Environment division. Dat