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.
COBOL, short for Common Business-Oriented Language, was defined by the CODASYL committee in 1959, drawing on Grace Hopper's earlier FLOW-MATIC compiler, to make business data processing readable in near-English syntax. Programs are organized into four divisions - Identification, Environment, Data, and Procedure - and verbs like DISPLAY, MOVE, and PERFORM were meant to be legible to accountants and auditors, not only engineers. It remains the backbone of mainframe systems in banking, insurance, payroll, and government, where a widely cited industry estimate puts around $3 trillion of daily transactions on COBOL code. On XCODX your program is compiled with GnuCOBOL (the exact version is shown in the badge) and run in a cloud sandbox, so you can try the language without a mainframe or emulator. GnuCOBOL accepts both traditional fixed-format source, where areas begin in specific columns, and modern free format.
IDENTIFICATION DIVISION.
PROGRAM-ID. SUMDEMO.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-I PIC 9(2) VALUE 0.
01 WS-TOTAL PIC 9(4) VALUE 0.
PROCEDURE DIVISION.
DISPLAY "Hello from COBOL!"
PERFORM VARYING WS-I FROM 1 BY 1 UNTIL WS-I > 10
ADD WS-I TO WS-TOTAL
END-PERFORM
DISPLAY "Sum of 1 to 10 = " WS-TOTAL
STOP RUN.
COBOL's strengths are fixed-point decimal arithmetic that avoids floating-point rounding errors, a record-and-file model built for batch processing, and readable structure that has kept programs maintainable for decades. Choose it when you are working on or learning the mainframe systems that run core banking, insurance claims, and government benefit calculations, where exact money math and stability matter more than novelty. It is a poor fit for web front ends, mobile apps, or quick scripting, where its ceremony and word count slow you down. In this sandbox it is best for practicing the divisions, PERFORM loops, and PIC clauses rather than the file and database work it does on real systems.
Use the ACCEPT verb, for example ACCEPT WS-NAME, and the typed value goes into that working-storage field. XCODX gives you a live terminal that pauses at the ACCEPT so you can type a line, or you can paste everything into the Stdin Box before running, and Ctrl+D closes the stream. Because ACCEPT reads into a fixed PIC field, size the field for the input you expect - a PIC 9(4) field, for instance, holds up to four digits.
No. The sandbox runs a single COBOL program with GnuCOBOL and nothing else - there is no CICS transaction manager, no DB2 or other database, no JCL, and no network to reach one. You get the core language and its intrinsic functions, so ACCEPT, DISPLAY, arithmetic, and in-memory data handling work, but anything that depends on a mainframe subsystem does not.
Fixed format is the traditional layout where columns 1-6 hold sequence numbers, column 7 is an indicator, and code sits in Area A (columns 8-11) and Area B (12-72). Free format drops those column rules so you can indent freely. GnuCOBOL defaults to fixed format, so keep division headers and 01 levels starting around column 8; to switch you can place the directive >>SOURCE FORMAT IS FREE on the first line.
Yes. Core systems in banking, insurance, payroll, and public-sector agencies still run large COBOL codebases on mainframes, and much of that code processes financial transactions every day. The demand comes less from new projects than from maintaining and modernizing these systems as experienced programmers retire. Trying the language here is a low-friction way to start reading and understanding that code.
COBOL was deliberately designed in 1959 to read like structured English so that business staff and auditors, not only programmers, could follow the logic. That is why you write ADD 1 TO COUNTER instead of counter++, and why every program is split into divisions. The word count trades keystrokes for readability, which is part of why decades-old programs stay maintainable.
In practice you need the IDENTIFICATION DIVISION with a PROGRAM-ID and the PROCEDURE DIVISION that holds your statements. The ENVIRONMENT and DATA divisions are optional and can be left out when a program has no files or working-storage variables. GnuCOBOL will compile a minimal program with just identification and procedure, ending in STOP RUN.
main.cbltext/x-cobolACCEPT IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
DISPLAY "Hello from COBOL!".
DISPLAY "Welcome to XCODX Online Compiler!".
STOP RUN.