Tuesday, November 23, 2010

Program to find sum of the digits of a number

    Murach's CICS for the COBOL Programmer    Murach's Structured COBOL     Micro Focus Visual Object Cobol 32 Bit 
    Identification Division.
       Program-ID.
       Environment Division.
       Data Division.
       Working-Storage Section.
       77 Sum PIC 9(4) Value 0.
       77 N PIC 9(6).
       77 Temp PIC 9(6).
       77 Rem PIC 9.
       Procedure division.
       Main-Para.
           Display "Enter Number (Maximum 6 digits) :".
           Accept N.
           Move N To Temp.
           Perform Para-1 Until N = 0.
           Display "Sum of the digit of " Temp " digit number " Sum.
           Stop Run.
       Para-1.
           Divide N BY 10 Giving N Remainder Rem.
           Compute Sum = Sum + Rem.

3 comments:

  1. How to rectify the following error

    No Input files

    ReplyDelete
  2. How to rectify the following error

    No Input files

    ReplyDelete
    Replies
    1. IS the Program Is Compiling Or getting any errors

      Delete