Workspace

COBOL

business systems records reports and legacy enterprise maintenance

Definition first

What COBOL means

COBOL is a programming language for writing exact instructions, often used for business systems records reports and legacy enterprise maintenance. Start with one mental model: input goes through steps and becomes output.

Minimum run factsFile main.cobRun cobc -x main.cob && ./mainHabit Read data divisions slowly and keep record layouts explicit
Program

An ordered set of instructions. It reads input, follows rules, and produces output.

Value and variable

A value is data. A variable is the name you use to hold and reuse that data.

Function

A named piece of work. It takes input, does one job, and can return a result.

Runtime

GnuCOBOL is the place that actually runs code from main.cob.

First readable code

Program output

entry point output syntax DISPLAY
DISPLAY 42.
Output 42

Language lineage

COBOL family tree

See where COBOL comes from, which languages feel close, and what to learn next.

roots
FLOW-MATICEnglish-like business code
currentCOBOLBusiness legacy family
familyBusiness legacy family
best used for

banking systems, records, reports, and legacy business logic

Zero base path

1Read one rule2Predict output3Type from memory4Run checklist5Repeat with one change

Question bank

Search before practice

Pick a stage or search across the open programming bank. Jump straight to the matching drill.

18 matching questions
Q 1ChoiceStage 1 definitions

COBOL practice 1

COBOL question 1. Choose the statement that matches printing a value.

Q 2ChoiceStage 1 definitions

COBOL practice 2

COBOL question 2. Choose the statement that matches naming a value.

Q 3ChoiceStage 1 definitions

COBOL practice 3

COBOL question 3. Choose the statement that matches reusable function.

Q 4ChoiceStage 1 definitions

COBOL practice 4

COBOL question 4. Choose the statement that matches basic collection.

Q 5ChoiceStage 1 definitions

COBOL practice 5

COBOL question 5. Choose the statement that matches printing a value.

Q 6ChoiceStage 1 definitions

COBOL practice 6

COBOL question 6. Choose the statement that matches naming a value.

Q 7ChoiceStage 1 definitions

COBOL practice 7

COBOL question 7. Choose the statement that matches reusable function.

Q 8ChoiceStage 1 definitions

COBOL practice 8

COBOL question 8. Choose the statement that matches basic collection.

Q 9ChoiceStage 1 definitions

COBOL practice 9

COBOL question 9. Choose the statement that matches printing a value.

Q 10ChoiceStage 1 definitions

COBOL practice 10

COBOL question 10. Choose the statement that matches naming a value.

Q 11ChoiceStage 1 definitions

COBOL practice 11

COBOL question 11. Choose the statement that matches reusable function.

Q 12ChoiceStage 1 definitions

COBOL practice 12

COBOL question 12. Choose the statement that matches basic collection.

Q 13ChoiceStage 1 definitions

COBOL practice 13

COBOL question 13. Choose the statement that matches printing a value.

Q 14ChoiceStage 1 definitions

COBOL practice 14

COBOL question 14. Choose the statement that matches naming a value.

Q 15ChoiceStage 1 definitions

COBOL practice 15

COBOL question 15. Choose the statement that matches reusable function.

Q 16ChoiceStage 1 definitions

COBOL practice 16

COBOL question 16. Choose the statement that matches basic collection.

Q 17ChoiceStage 1 definitions

COBOL practice 17

COBOL question 17. Choose the statement that matches printing a value.

Q 18ChoiceStage 1 definitions

COBOL practice 18

COBOL question 18. Choose the statement that matches naming a value.

Multiple choice

COBOL practice 1

Q 1Choicenew

COBOL question 1. Choose the statement that matches printing a value.

DISPLAY 42.

Reference

Patterns for main.cob

GnuCOBOLcobc -x main.cob && ./main
Recall from memoryRead a small point then write it back without looking
Trace the codeWrite variable values line by line before you run the answer
Type it yourselfCopy less type more and fix one small error at a time

entry point output syntax DISPLAY

Program output

DISPLAY 42.
  • Run the smallest file first
  • Print one known value
  • Check the output before adding more code

variables assignment types PIC

Values and names

01 TOTAL PIC 99 VALUE 42.
DISPLAY TOTAL.
  • Give values readable names
  • Keep one idea per line while learning
  • Trace the value before changing it

function collection OCCURS

Functions and collections

ADD A TO B GIVING RESULT.

01 SCORES OCCURS 2 TIMES PIC 99.
DISPLAY SCORES(1).
  • Keep functions small
  • Return useful values
  • Use the common collection before reaching for frameworks