Part 1
Fundamentals
Divisions, PICTURE clauses, arithmetic, control flow: the language from the ground up.
Part 1 is where the language starts: the shape of a program and the handful of statements every later lesson leans on. It has five lessons, each a complete GnuCOBOL program with its listing. All five were compiled and run with GnuCOBOL 3.2 and show that run's output: four on 29 October 2026 and the fifth, on MOVE truncation, on 30 October 2026, when it was also compiled under the IBM and Micro Focus dialects (how this site is made explains the labels).
Start with your first COBOL program, which walks through the four divisions, DISPLAY and STOP RUN; every later lesson on the site builds on that shape. Read the PICTURE clause next, because a PICTURE is both a type and a memory layout, and the two lessons after it depend on that. MOVE and its truncation rules shows the seven cases where COBOL cuts data on the right or the left, drops a sign, or copies bytes blindly, all without an error. COMPUTE, ROUNDED and ON SIZE ERROR shows how exact decimal arithmetic overflows silently unless you ask it not to. The part closes with PERFORM in all its shapes, COBOL's one looping statement, with a table of when each loop tests its condition.
If you are arriving from another language, do not skip the MOVE lesson: it is the one most likely to explain a bug in code you have inherited. From here, Data and Tables builds records and tables out of these pieces. Still to come in this part: EVALUATE, the intrinsic functions (FUNCTION CURRENT-DATE, NUMVAL, TRIM) and nested programs.
1.1
Your first COBOL program: all four divisions, DISPLAY, STOP RUN
A complete first COBOL program for GnuCOBOL, explained division by division, with DISPLAY, WITH NO ADVANCING, signed and unsigned numbers, and STOP RUN.
7 min
1.2
COBOL PICTURE clause: 9, X, A, V, S and how a number is stored
What each PICTURE symbol means, how PIC 9(3)V99 occupies five bytes with no decimal point, and what S and P really do, shown by one GnuCOBOL program.
6 min
1.3
COBOL MOVE statement and the truncation rules that surprise everyone
Seven MOVEs in one GnuCOBOL program show where COBOL truncates on the right, on the left, drops a sign, or copies bytes blindly in a group move, with a rules table.
11 min
1.4
COMPUTE, ROUNDED, ON SIZE ERROR: COBOL arithmetic without overflow
One GnuCOBOL program: COMPUTE with and without ROUNDED, ROUNDED MODE IS NEAREST-EVEN on a tie, an overflow caught by ON SIZE ERROR, and a trapped divide by zero.
9 min
1.5
PERFORM VARYING, PERFORM UNTIL, and inline PERFORM in COBOL
Every common COBOL loop in one GnuCOBOL program: PERFORM TIMES, UNTIL with TEST BEFORE and TEST AFTER, inline VARYING over a table, nested AFTER, and EXIT PERFORM.
6 min