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

Program for subtract verb, PROGRAM FOR SUBTRACT VERB: We have to write...

PROGRAM FOR SUBTRACT VERB: We have to write a simple program to elaborate the SUBTRACT verb. You can also use edit characters in the program. Identification division. Pr

Character set - cobol programming, Character Set: To study any languag...

Character Set: To study any language, first one should know the alphabets of the language and they are termed as character set in general. There are 50 different characters in

Concept of a two-dimensional table, Concept of a two-dimensional table: ...

Concept of a two-dimensional table: Concept of a two-dimensional table can be easily extended to tables having three or more dimensions. The Handling of tables up to three dim

Cobol program, Write a COBOL IF sentence to use the values of numeric var...

Write a COBOL IF sentence to use the values of numeric variables EXAM and COURSEWORK , both assumed to be with format PIC 999 and in the range 0 to 100 and to move the value:

#title.cobol help , we have input file ,record layout is EMP ID (6 char) , ...

we have input file ,record layout is EMP ID (6 char) , EMP NAME (20 char), Designation (3 char),Salary (5 digit) Base Branch (10char) Grade (3 Alphanumeric). This is the input file

Program to demonstrate merge verb, PROGRAM TO DEMONSTRATE MERGE VERB: ...

PROGRAM TO DEMONSTRATE MERGE VERB: The two files for which a record having 2 fields viz. Account Number and Name are already available. Now Merge these two files and create a

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

Read statement, READ STATEMENT: The aim of this verb is to make availa...

READ STATEMENT: The aim of this verb is to make available the next logical record from the input file. It is important to note the meaning of the "next" logical record in the

Go to, GO TO, STOP RUN: The GO TO verb is used to completely transfer ...

GO TO, STOP RUN: The GO TO verb is used to completely transfer the control to elsewhere in the program. Its form is as shown below: GO TO procedure-name As a result o

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