The error messages are:
fizzbuzz.cob:12: error: PERFORM statement not terminated by END-PERFORM fizzbuzz.cob:18: error: syntax error, unexpected END-PERFORM
I'm getting a compile error with this program because it says that the
PERFORM statement needs an
END-PERFORM, but it also says that the
END-PERFORM is unexpected. I'm confused as to why it doesn't seem to compile, what is the error here?
000100 IDENTIFICATION DIVISION. 000110 AUTHOR. AMBER. 000200 PROGRAM-ID. FIZZBUZZ. 000300 ENVIRONMENT DIVISION. 000400 DATA DIVISION. 000500 FILE SECTION. 000600 WORKING-STORAGE SECTION. 000700 01 WS-I PIC 99 VALUE 1. 000800 01 WS-R PIC 99. 000810 01 WS-NO PIC 99. 000900 PROCEDURE DIVISION. 001000 PERFORM UNTIL WS-I = 99 001100 DIVIDE WS-I BY 3 GIVING WS-NO REMAINDER WS-R 001200 IF WS-R = 0 DISPLAY "FIZZ" 001210 ELSE DISPLAY WS-I 001220 END-IF 001230 ADD 1 TO WS-I IF WS-I < 99 001240 END-PERFORM. 001300 STOP RUN. 001400 END PROGRAM FIZZBUZZ.
The intention is to have the program do the first half of a
FIZZBUZZ program, just replacing all the numbers divisible by 3 with the string "FIZZ".
I am using GnuCOBOL to compile. The system is running on Pop_os! Linux
I tried placing a full stop/period at several points in the program, actually, the first compile error comes from having a full stop at the end of line 16. I suspect it's a formatting error.
While I would expect the compiler to point to this line and flag it as an error, it did not. However, this is the line causing the compilation error, despite the message:
001230 ADD 1 TO WS-I IF WS-I < 99
"IF WS-I < 99" followed by END-PERFORM represent an incomplete IF statement.