1. Home
  2. /
  3. Cobol
  4. /
  5. Simple Addition

Simple Addition - Cobol Typing CST Test

Loading…

Simple Addition — Cobol Code

Adds two numbers and displays the result.

       IDENTIFICATION DIVISION.
       PROGRAM-ID. AddProgram.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 A   PIC 9(4) VALUE 5.
       01 B   PIC 9(4) VALUE 3.
       01 SUM PIC 9(4) VALUE 0.

       PROCEDURE DIVISION.
       ADD A TO B GIVING SUM
       DISPLAY 'Sum: ' SUM
       STOP RUN.

Cobol Language Guide

COBOL (Common Business-Oriented Language) is a high-level, English-like programming language designed for business applications, financial systems, batch processing, and large-scale enterprise data operations. Known for reliability, readability, and long-term stability.

Primary Use Cases

  • ▸Banking and financial transaction systems
  • ▸Payroll and HR systems
  • ▸Insurance policy and claims processing
  • ▸Government mainframe workloads
  • ▸Batch data processing
  • ▸Large-scale enterprise reporting

Notable Features

  • ▸English-like syntax for clarity
  • ▸Exceptional stability for long-running systems
  • ▸Massive legacy ecosystem in enterprises
  • ▸Strong support for structured data processing
  • ▸Designed for business rules rather than hardware

Origin & Creator

Developed in 1959 by CODASYL (Conference on Data Systems Languages), with major contributions from Grace Hopper and the US Department of Defense.

Industrial Note

COBOL still powers core banking, insurance, payroll, and government systems worldwide - often handling billions of daily transactions in mission-critical environments.

Quick Explain

  • ▸COBOL is optimized for business data processing, not system-level or performance-critical tasks.
  • ▸It features a verbose, English-like syntax designed for readability by non-programmers in the 1960s.
  • ▸Used extensively in banking, insurance, government, and enterprise legacy systems for decades.

Core Features

  • ▸DIVISION-based program structure
  • ▸Built-in file handling for sequential and indexed data
  • ▸Extensive record definitions via DATA DIVISION
  • ▸Procedural logic through PROCEDURE DIVISION
  • ▸Batch processing and transaction support

Learning Path

  • ▸Start with basic COBOL syntax and divisions
  • ▸Learn PIC data types and file handling
  • ▸Practice sequential & indexed file operations
  • ▸Study batch processing with JCL
  • ▸Explore enterprise-level systems and DB2 integration

Practical Examples

  • ▸Payroll calculation program
  • ▸Banking transaction batch processor
  • ▸Insurance policy renewal logic
  • ▸Reading/writing indexed files
  • ▸Generating enterprise reports

Comparisons

  • ▸More verbose than modern languages
  • ▸Far more stable for business logic
  • ▸Better suited for batch than real-time apps
  • ▸Strong legacy support vs modern innovation
  • ▸More maintainable for long-term enterprise systems

Strengths

  • ▸Highly readable and self-documenting
  • ▸Rock-solid stability for mission-critical systems
  • ▸Excellent for large-scale batch processing
  • ▸Unmatched legacy compatibility
  • ▸Decades of proven reliability in finance/government

Limitations

  • ▸Verbose syntax compared to modern languages
  • ▸Not suited for modern web/app development
  • ▸Small pool of new COBOL developers
  • ▸Mainframe ecosystem can be expensive
  • ▸Limited abstraction mechanisms

When NOT to Use

  • ▸Web or mobile app development
  • ▸High-performance graphics or gaming
  • ▸Real-time systems programming
  • ▸Startups needing rapid iteration
  • ▸Projects requiring modern paradigms

Cheat Sheet

  • ▸IDENTIFICATION DIVISION.
  • ▸DATA DIVISION.
  • ▸PROCEDURE DIVISION.
  • ▸PERFORM UNTIL condition ... END-PERFORM.
  • ▸MOVE value TO variable.

FAQ

  • ▸Is COBOL still used?
  • ▸Yes - it powers a massive amount of global financial and government infrastructure.
  • ▸Is COBOL easy to learn?
  • ▸Syntax is simple but verbose.
  • ▸Does COBOL run on modern systems?
  • ▸Yes - through GnuCOBOL and enterprise tools.
  • ▸Is COBOL only on mainframes?
  • ▸Primarily, but it can run on Windows/Linux via compilers.

30-Day Skill Plan

  • ▸Week 1: Syntax & divisions
  • ▸Week 2: File input/output
  • ▸Week 3: Batch processing & JCL
  • ▸Week 4: Complex business logic & DB2

Final Summary

  • ▸COBOL remains essential for enterprise data processing.
  • ▸Highly stable and readable for long-term business applications.
  • ▸Integral to banking, government, and financial operations.
  • ▸New developers are needed to maintain aging legacy systems.

Project Structure

  • ▸source.cob
  • ▸copybooks (.cpy)
  • ▸JCL scripts for batch execution (mainframe)
  • ▸Compiled binary or mainframe load module
  • ▸Dataset definitions

Monetization

  • ▸COBOL modernization consulting
  • ▸Mainframe development roles
  • ▸Financial/enterprise contract work
  • ▸Government system maintenance
  • ▸COBOL-cloud integration services

Productivity Tips

  • ▸Use copybooks for reuse
  • ▸Structure programs into clear sections
  • ▸Leverage mainframe debugging tools
  • ▸Validate data formats early
  • ▸Comment complex business logic extensively

Basic Concepts

  • ▸Divisions and sections
  • ▸Variables and data types via PIC clauses
  • ▸Records and file structures
  • ▸Procedural flow with PERFORM statements
  • ▸Batch input/output and file operations

Official Docs

  • ▸ISO COBOL standards
  • ▸IBM Enterprise COBOL documentation
  • ▸GnuCOBOL user manual

More Cobol Typing Exercises

COBOL Counter and Theme ToggleCOBOL FactorialCOBOL Fibonacci SequenceCOBOL Array SumCOBOL Max of Two NumbersCOBOL Reverse StringCOBOL Even Numbers FilterCOBOL String Concatenation

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher