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
PERFORM STATEMENT:   The PERFORM statement can be used to execute the group of consecutive statements written elsewhere in the program. We refer to this group of statements a

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

ADD VERB: The ADD Verb can be used to find the sum of two or more numbers and to store the sum.  The ADD verb takes any one of the two forms as shown below:

Rules for constructing an Arithmetic Expression: The rules for constructing an arithmetic expression are as shown below: (i) When an arithmetic expression specifies a calcu

Buffers: The Modern computers are able of handling I-O operations independent of the CPU by means of the hardware termed as data channel. For illustration, if two buffers a

FILE UPDATION: The method of modifying an old file with present information is termed as file updating. Master file: A master file is a file which is used as an author

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

When using the accept verb in cobol is it possible to assign something other then "SYSIN" for a ddname?

CR and DB (Credit and Debit Sign): The two characters that is CR or DB symbol may appear only at the rightmost place of the picture. They are similar to the minus sign edit ch

Example of Redefines clause: This illustration describes a sales record that may either contain the total amount of sale or the quantity (QTY) and UNIT-PRICE. The aim of such