Example of if- else statement, COBOL Programming

Example of If- else statement

Illustration:

  IF   QUANTITY IS NUMERIC AND QUANTITY IS POSITIVE 

        MOVE ZERO TO ERROR-CODE. COMPUTE SALES VALUE=QUANTITY*RATE                     

  ELSE MOVE 1 TO ERROR -CODE 

        MOVE ZERO TO SALES-VALUE  

The particular condition tests whether or not the present value of the data name QUANTITY is numeric as well as positive. If the condition is true then ERROR-CODE is set to zero and SALES-VALUE is computed by multiplying the QUANTITY by RATE. On the other hand, when the condition is FALSE, then ERROR CODE is set to 1 and SALES-VALUE is set to zero. In either situation the control goes implicitly to the next statement after this IF sentence. The above sentence is equal to the following flowchart.

971_Example of If- else statement.png

Posted Date: 10/17/2012 1:54:42 AM | Location : United States







Related Discussions:- Example of if- else statement, Assignment Help, Ask Question on Example of if- else statement, Get Answer, Expert's Help, Example of if- else statement Discussions

Write discussion on Example of if- else statement
Your posts are moderated
Related Questions
ADD and SUBTRACT CORRESPONDING: The CORRESPONDING option can also used with the ADD and SUBTRACT verbs. The following are some of the formats of these verbs with the CORRESPON

Examples - Edit characters for numeric data: The following illustration illustrates the use of Z editing characters. The character b is used to indicate the space character an

Example of Class condition: Let the BASIC-PAY be a data name in the card record defined with picture 9(5) V99. By reading the card we can test the value of the BASIC-PAY to ma

Common form of the READ statements: Format 1 is the common form of the READ statements. Format 2 is used when the access mode is either random or dynamic. For illustration,

PROGRAM FOR SCREEN SECTION:  identification division.   program- id.   environment division.   data division.   working-storage section.   01  a pic 9(2) value

INPUT AND OUTPUT PROCEDURE IN SORT STATEMENT: The common format of the SORT statement can write as shown below: The format of the RELEASE statement is as shown be

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

RELATIONAL CONDITION:   We know that a relational condition specifies a comparison between two operands and has the form.     Operand-1    relational-operator   operand-2

Example of Nested if statement: Illustration: Consider the following sentence The nested IF sentence holds two IFs and one ELSE. The IF-ELSE couple has been marke

PROGRAM FOR INDEXED SEQUENTIAL FILE CREATION: We have to write a program to create an Indexed Sequential File in a dynamic mode for Student particulars. Suppose just 3 fields: