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:
Chat with our AI personalities
program to find maximum of two numbers using pointers
VBnet program to find the prime numbers between 100 to 200?
for(int i = 1; i < 100; i+=2) { System.out.println(i); }
This would require some computer knowledge. It can make it easier to find out the prime numbers without figuring it out in your head.
Yes, do write. That's what you always have to do when you have got a homework-program.