An ordered set of instructions. It reads input, follows rules, and produces output.
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.
main.cobRun cobc -x main.cob && ./mainHabit Read data divisions slowly and keep record layouts explicitA value is data. A variable is the name you use to hold and reuse that data.
A named piece of work. It takes input, does one job, and can return a result.
GnuCOBOL is the place that actually runs code from main.cob.
First readable code
Program output
entry point output syntax DISPLAYDISPLAY 42.
Output 42Language lineage
COBOL family tree
See where COBOL comes from, which languages feel close, and what to learn next.
Zero base path
Question bank
Search before practice
Pick a stage or search across the open programming bank. Jump straight to the matching drill.
COBOL practice 1
COBOL question 1. Choose the statement that matches printing a value.
COBOL practice 2
COBOL question 2. Choose the statement that matches naming a value.
COBOL practice 3
COBOL question 3. Choose the statement that matches reusable function.
COBOL practice 4
COBOL question 4. Choose the statement that matches basic collection.
COBOL practice 5
COBOL question 5. Choose the statement that matches printing a value.
COBOL practice 6
COBOL question 6. Choose the statement that matches naming a value.
COBOL practice 7
COBOL question 7. Choose the statement that matches reusable function.
COBOL practice 8
COBOL question 8. Choose the statement that matches basic collection.
COBOL practice 9
COBOL question 9. Choose the statement that matches printing a value.
COBOL practice 10
COBOL question 10. Choose the statement that matches naming a value.
COBOL practice 11
COBOL question 11. Choose the statement that matches reusable function.
COBOL practice 12
COBOL question 12. Choose the statement that matches basic collection.
COBOL practice 13
COBOL question 13. Choose the statement that matches printing a value.
COBOL practice 14
COBOL question 14. Choose the statement that matches naming a value.
COBOL practice 15
COBOL question 15. Choose the statement that matches reusable function.
COBOL practice 16
COBOL question 16. Choose the statement that matches basic collection.
COBOL practice 17
COBOL question 17. Choose the statement that matches printing a value.
COBOL practice 18
COBOL question 18. Choose the statement that matches naming a value.
Multiple choice
COBOL practice 1
COBOL question 1. Choose the statement that matches printing a value.
DISPLAY 42.
Reference
Patterns for main.cob
cobc -x main.cob && ./mainentry 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