123456*
IDENTIFICATION DIVISION.
PROGRAM-ID. "EVEN-OR-ODD".
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Num-1 PIC 9(02).
02 Answer PIC XXXX.
PROCEDURE DIVISION.
GOBACK.
EVEN-OR-ODD.
IF FUNCTION REM(NUM-1, 2) = 0
COMPUTE ANSWER = "Even"
ELSE
COMPUTE ANSWER = "Odd"
END-IF
END PROGRAM EVEN-OR-ODD.
Its a simple even odd function. It should check if number is even return "even" else return "odd" Can someone explain what's wrong ?
So much things a COBOL compiler would have told you...
GOBACK
as first statement, so the rest would not be executedEND PROGRAM
is only parsed for the compilation phase) - you likely want to move your GOBACK.
to the endCOMPUTE
does not set anything to alphanumeric, you likely want MOVE
DISPLAY
instead of MOVE
NUM-1
is never set and has no initial VALUE
- so it could theoretically even abend