Tuesday, November 23, 2010

Find the largest and the largest position

       Identification Division.
       Program-ID.
       Environment Division.
       Data Division.
       Working-Storage Section.
       77 Max PIC 9(4) Value 0.
       77 N PIC 9(4).
       77 Pos PIC 99 Value 0.
       77 LargePos PIC 99 Value 0.
       77 Choice PIC A.
       Procedure division.
       Main-Para.
           Perform Para-1 Until Choice = "N" OR Choice = "n".
           Display "Largest Number is " Max.
           Display "Largest Number Position : " LargePos.
           Stop Run.
       Para-1.
           Display "Enter A number : "
           Accept N.
           Compute Pos = Pos + 1.
           IF N > Max
               Compute Max = N
               Compute LargePos = Pos.
           Display "Do You want to enter any Value (Y/N) : "
           Accept Choice.

No comments:

Post a Comment