Tuesday, November 23, 2010

Program to find reverse of a number.

    A Simplified Guide to Structured COBOL Programming                                                     
      Identification Division.
       Program-ID. reverse.
       Environment Division.
       Data Division.
       Working-Storage Section.
       77 N PIC 9(6).
       77 Temp PIC 9(6).
       77 Rem PIC 9.
       77 Rev PIC 9(6) Value Zeros.
       Procedure division.
       Main-Para.
           Display "Enter Number (Maximum 6 digits) : ".
           Accept N.
           Move N TO Temp.
           Perform Para-1 Until N = 0.
           Display "Reverse of " Temp " is " Rev.
           Stop Run.
       Para-1.
           Divide N BY 10 Giving N Remainder Rem.
           Compute Rev = Rev * 10 + Rem.

1 comment:

  1. Can you please share the program to find the place value of a digit from left to right in cobol.

    ReplyDelete