answersLogoWhite

0

1. (B) WRITE A PROGRAM TO FIND THE SUM OF INDIVIDUAL DIGITS IN THE GIVEN 'n'

DIGIT DECIMAL NUMBER.

IDENTIFICATION DIVISION.

PROGRAM-ID. PRO.

ENVIRONMENT DIVISION.

DATA DIVISION.

WORKING-STORAGE SECTION.

77 NUM PIC ZZZ9.

77 N PIC 9999.

77 SUM PIC 9(4) VALUE 0.

77 R PIC 9.

77 SUM1 PIC Z(4)9.

PROCEDURE DIVISION.

PARA1.

DISPLAY " ENTER THE NUMBER ".

ACCEPT N.

MOVE N TO NUM.

DISPLAY " ".

DISPLAY " THE NUMBER IS : " NUM.

PERFORM PARA2 UNTIL N = 0.

MOVE SUM TO SUM1.

DISPLAY " ".

DISPLAY " THE SUM OF NUM IS " SUM1.

STOP RUN.

PARA2.

DIVIDE N BY 10 GIVING N REMAINDER R.

COMPUTE SUM = SUM + R.

OUTPUT:

User Avatar

Wiki User

12y ago

Still curious? Ask our experts.

Chat with our AI personalities

CoachCoach
Success isn't just about winning—it's about vision, patience, and playing the long game.
Chat with Coach
FranFran
I've made my fair share of mistakes, and if I can help you avoid a few, I'd sure like to try.
Chat with Fran
ReneRene
Change my mind. I dare you.
Chat with Rene

Add your answer:

Earn +20 pts
Q: Write cobol program to find sum of two numbers?
Write your answer...
Submit
Still have questions?
magnify glass
imp