Program for if -else, COBOL Programming

PROGRAM FOR IF -ELSE:

We have to write a program to check whether the given number is ODD or EVEN. You can use IF..ELSE.

Identification division.

Program- id. IfElse.

Environment division.

Data division.

Working-storage section.

01 n pic 9(3) value 0.

01 q pic 9(3) value 0.

01 r pic 9(3) value 0.

Procedure division.

Para-1.

  Display(1 1) erase.

  Display( 3 5) " Enter a Number :".

  Accept n.

  Divide n by 2 giving q remainder r.

            If  (r = 0) 

                 Display(10 5) " EVEN NUMBER"

            else      

                 Display(10 5) " ODD NUMBER".

             Stop run.

Posted Date: 10/17/2012 7:43:05 AM | Location : United States







Related Discussions:- Program for if -else, Assignment Help, Ask Question on Program for if -else, Get Answer, Expert's Help, Program for if -else Discussions

Write discussion on Program for if -else
Your posts are moderated
Related Questions
How do i write a simple cobol programming that works

Illustration of perform statement: PERFORM    CALCUALTE-TAX. In this illustration, the CALCULATE-TAX is either a section name or paragraph name. Assume that it is a section

Illustration of Subtract verb: (a) SUBTRACT A FROM B. This illustration means that the value of A will be subtracted from the value of B and the subtracted result will be s

Program for Sequential File Creation & Rewriting  We have to write a program to create a Length file with just two fields: l (Length) and l-c (Length-Code). Add a few records.

FILLER CLAUSE: Consider the statements as shown below: 1)  01    f    pic     x(80)  value    all "-". This statement origins a line of 80 characters filled with "-"

calculate simple interest

PROGRAM FOR MOVE CORRESPONDING: We have to write a simple program to demonstrate Move Corresponding. identification division.   program- id.   environment division.

ARITHMETIC VERBS: Most of the problems need some computations to be performed on the input or intermediate data that are numeric in nature. The Arithmetic verbs are used to pe

Edit Characters for Numeric Data: The characters below can be used in the PICTURE clause to indicate the editing.   Z    *  $  -    +    CR    DB    .    ,    B    O    /

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