Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
By most estimates, hundreds of billions of lines of COBOL are still in production — processing bank transactions, insurance claims, payroll runs, and government benefits every single day. Designed in 1959 with Grace Hopper's ideas at its core, COBOL was built to read like business English and to handle exact decimal arithmetic, which is precisely why finance never left it. The language is not frozen: the ISO COBOL 2023 standard is current, IBM ships new Enterprise COBOL releases, and the open-source GnuCOBOL compiler makes learning it free. With mainframe veterans retiring, modernization teams actively recruit developers who can read COBOL. This page compiles COBOL and runs it in a live terminal where ACCEPT statements wait for your real typed input.
IDENTIFICATION DIVISION.
PROGRAM-ID. INTEREST-DEMO.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 USER-NAME PIC X(30).
01 NUM-YEARS PIC 9(2).
01 ACCT-BALANCE PIC 9(7)V99 VALUE 1000.00.
01 YEAR-COUNT PIC 9(2) VALUE 0.
01 SHOW-BALANCE PIC $Z,ZZZ,ZZ9.99.
PROCEDURE DIVISION.
DISPLAY "What is your name? " WITH NO ADVANCING.
ACCEPT USER-NAME.
DISPLAY "Hello, " FUNCTION TRIM(USER-NAME) "!".
DISPLAY "Grow $1000 at 5% for how many years? "
WITH NO ADVANCING.
ACCEPT NUM-YEARS.
PERFORM NUM-YEARS TIMES
COMPUTE ACCT-BALANCE = ACCT-BALANCE * 1.05
ADD 1 TO YEAR-COUNT
END-PERFORM.
MOVE ACCT-BALANCE TO SHOW-BALANCE.
DISPLAY "After " YEAR-COUNT " years: " SHOW-BALANCE.
STOP RUN.
COBOL is a career play: banks, insurers, and government agencies in the US, UK, Canada, and Australia run core systems on it and pay well for people who can maintain and modernize them — IBM's mainframe training initiatives exist precisely because demand outstrips supply. Use this page to learn the fundamentals recruiters screen for: DIVISION structure, PIC clauses and decimal arithmetic, PERFORM loops, and formatted output. It's also practical for developers on modernization projects who need to decode a copybook or verify how a COMPUTE rounds before touching production JCL.
Yes — ACCEPT pauses the program until you type a value in the terminal, and DISPLAY ... WITH NO ADVANCING keeps the prompt on the same line, so the classic prompt-and-respond flow works exactly like a terminal-attached batch program. Multiple ACCEPT statements in sequence each wait for their own input.
Programs compile with GnuCOBOL, the open-source compiler that translates COBOL to C. It follows the standards closely and supports most IBM-style syntax, so the core language you practice — data division layouts, PERFORM, COMPUTE, intrinsic functions — transfers directly to Enterprise COBOL, though mainframe-specific facilities like CICS and DB2 precompilers won't exist here.
In traditional fixed-format COBOL, yes: area A starts at column 8 and statements begin in area B at column 12, which is why the example indents with seven leading spaces. GnuCOBOL also supports free-format source, but learning fixed format is wise since virtually all legacy mainframe code uses it.
main.cbltext/x-cobolACCEPT IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
DISPLAY "Hello from COBOL!".
DISPLAY "Welcome to XCODX Online Compiler!".
STOP RUN.