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
, (Comma) : A comma, whenever used in a picture, is considered as an insertion character and inserted wherever it become visible. There can be more than one comma in the pictu

PROGRAM FOR CONDITION NAMES: We have to write a simple program to demonstrate Condition names usage.  identification division.   program- id.   environment division.

STATEMENTS FOR SEQUENTIAL FILES: A basic operation on a file includes the reading and writing of its records. Whenever the file is sequential, there are three verbs for the

RULES OF RENAMES CLAUSE:   The rules below should be observed while using the RENAMES clause: (i) All RENAMES entries should be written only after the last record descript

Illustration of Renames clause: In the illustration, PAT-OTHER-THAN-BASIC will become a fresh group consisting of DEARNESS-ALLOWANCE, HOUSE-RENT & MTHLY-INCENTIVE. Keep in min

Second form of Divide verb: The second form of this verb is as shown below: In this situation the identifier-1 or numeric- literal-1 will be divided by identifier-2 or

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

Illustration of Divide verb: (a) DIVIDE 5 INTO A. If the value of A is 20, then after execution of this statement the value of A will be 4. The older value of A will be los

Illustration of Multiply verb: (a)  MULTIPLY A BY B. In this situation the value of A & B will be multiplied and the product will be stored in B.  The decimal point locatio

COMPOUND CONDITION: The two simple conditions can be connected by the logical operators AND or OR to form a compound condition (also termed as combined condition). When two co