Fixed Format and the Column Rules

COBOL GnuCOBOL 3.2.0 Β· βœ“ verified by execution on 2026-08-16

If you find a snippet of COBOL from the 1980s and paste it into a modern compiler, there is a very high chance it will immediately crash with syntax errors. Why? Because historically, COBOL was punched into physical paper cards exactly 80 columns wide, and the compiler enforced strict rules about what could go in which column.

This legacy restriction is called fixed format. While modern environments (like CodeLudo) often use free format to let you type anywhere, you will encounter fixed format in the wild. Understanding the column rules is the single most common hurdle for a beginner trying to compile their first piece of real-world COBOL.

The 80-Column Punch Card

In fixed format, every line of code is rigidly divided into specific areas based on character columns.

cobol βœ“ verified output
       >>SOURCE FORMAT IS FIXED
000100 IDENTIFICATION DIVISION.                                         FIXEDFMT
000200 PROGRAM-ID. FIXED-FMT.                                           FIXEDFMT
000300*This is a comment in column 7.                                   FIXEDFMT
000400 PROCEDURE DIVISION.                                              FIXEDFMT
000500     DISPLAY "Fixed format works!".                               FIXEDFMT
000600     STOP RUN.                                                    FIXEDFMT
Output
Fixed format works!

Wait, what are those numbers at the beginning and the end? Let’s break down the anatomy of a fixed format line:

1-6 7 8-11 12-72 73-80 SEQ * A Area B (Statements) REF Columns 1-6: Sequence Numbers (Optional) Column 7: Indicator Area (* for comments) Columns 8-11: Area A (Division & Paragraph headers) Columns 12-72: Area B (Program logic & statements) Columns 73-80: Reference Area (Ignored)
  1. Columns 1-6 (Sequence Numbers): Historically used to sort dropped punch cards. Today, you can just leave these blank with 6 spaces.
  2. Column 7 (Indicator Area): Used for control characters. The most common is an asterisk (*) which turns the entire line into a comment.
  3. Columns 8-11 (Area A): High-level structural headers go here. IDENTIFICATION DIVISION, section names, paragraph names, and 01 level variables must start in Area A.
  4. Columns 12-72 (Area B): This is where the actual work happens. Execution statements like DISPLAY and STOP RUN must fit within Area B.
  5. Columns 73-80 (Reference Area): Historically used for program tags or patch IDs. The compiler completely ignores anything written here.

The Column 72 Truncation Bug

Because fixed format compilers strictly stop reading at column 72, any code that spills over into column 73 is silently discarded. This causes some of the most confusing bugs in COBOL history.

For example, if you write a string that is too long, the closing quote might land in column 73. The compiler ignores the quote, and crashes because it thinks you forgot to close the string!

       IDENTIFICATION DIVISION.
       PROGRAM-ID. OVERFLOW.
       PROCEDURE DIVISION.
           DISPLAY "This string goes past column 72 into the reference ar..
           STOP RUN.
error: missing terminating " character

Worse, if a variable declaration pushes its VALUE clause past column 72, the compiler silently ignores the initialization, leaving your variable full of uninitialized garbage spaces!

Predict the output cobol

Read the code. What exactly will it print? Commit to an answer before you look.

       >>SOURCE FORMAT IS FIXED
       IDENTIFICATION DIVISION.
       PROGRAM-ID. OVERFLOW2.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 LONG-NAME-THAT-IS-ALMOST-SEVENTY-TWO-CHARACTERS-LONG  PIC X(5) VALUE 'TEST!'.
       PROCEDURE DIVISION.
           DISPLAY LONG-NAME-THAT-IS-ALMOST-SEVENTY-TWO-CHARACTERS-LONG.
           STOP RUN.
Output
     

(Notice how the output is just blank spaces? The VALUE 'TEST!' was in column 73 and beyond!)

Welcome to Free Format

To save our sanity, modern compilers (including GnuCOBOL) support free format. In free format, the rigid column boundaries are completely removed. You can start your code in column 1, and lines can stretch all the way to 255 characters.

In CodeLudo, we compile all of your code in free format behind the scenes, so you don’t need to count spaces!

cobol βœ“ verified output
IDENTIFICATION DIVISION.
PROGRAM-ID. FREE-FMT.
*> In free format, comments use an asterisk and a greater-than sign!
PROCEDURE DIVISION.
DISPLAY "Free format works!".
STOP RUN.
Output
Free format works!

[!CAUTION] Comment syntax changes! In fixed format, you use an asterisk * in exactly column 7 to create a comment. In free format, column 7 means nothing, so you must use the *> symbol to start a comment anywhere on the line.

Check yourself

In COBOL fixed format, what must begin in Area A (Columns 8-11)?

Reveal answer

Division, section, and paragraph headers, plus 01 level numbers. β€” High-level structures like divisions, sections, paragraphs, and 01/77 level data items must start in Area A. Statements go in Area B, and comments go in column 7.

What happens if a string literal extends past column 72 in a strict fixed format COBOL file?

Reveal answer

The text beyond column 72 is truncated and ignored, which will cause a missing quote error. β€” Text beyond column 72 is completely ignored in fixed format. If a string is open and its closing quote lands past column 72, the quote is truncated, resulting in an unterminated string error.

Which of the following creates a comment in free format COBOL?

Reveal answer

An asterisk followed by a greater-than sign (*>) anywhere on the line. β€” Free format removes the column 7 indicator rule, so a bare asterisk is a syntax error. Free format COBOL uses `*>` to begin a comment.

Challenges

Challenge 1 +25 XP

The following code attempts to use a fixed format comment (`*`), but since CodeLudo runs your code in free format, it throws a syntax error! Change it to a free format comment (`*>`) so the program runs.

cobol βœ“ solution verified at build time

COBOL has no in-browser runtime, so this one is pen-and-paper: work out what the fixed code should be, then open the solution and compare. The expected output below is real β€” it came from compiling the solution with GnuCOBOL when this page was built.

  • Test 1 β€” expects "Hello!\n"
Need a hint? (βˆ’25% XP)

In free format, comments must use the `*>` symbol instead of just a `*`.

Show solution (0 XP)
IDENTIFICATION DIVISION.
PROGRAM-ID. FREE-FMT.
*> This is a comment in column 7, but we are in free format!
PROCEDURE DIVISION.
    DISPLAY "Hello!".
    STOP RUN.

🐞 Bug Hunt +25 XP

This code is broken! It has some random text that should have been commented out, but the `*>` symbol is missing. Add the free format comment symbol to the start of the line so the program compiles.

This code runs. It just does the wrong thing. Read it, find the defect, fix it β€” the tests below decide when you are right.

cobol βœ“ solution verified at build time

COBOL has no in-browser runtime, so this one is pen-and-paper: work out what the fixed code should be, then open the solution and compare. The expected output below is real β€” it came from compiling the solution with GnuCOBOL when this page was built.

  • Test 1 β€” expects "Will I run?\n"
Need a hint? (βˆ’25% XP)

Add `*>` to the beginning of the random text line.

Show solution (0 XP)
IDENTIFICATION DIVISION.
PROGRAM-ID. BAD-COMMENT.
*> This is just random text that is not commented out.
PROCEDURE DIVISION.
    DISPLAY "Will I run?".
    STOP RUN.