Day 3: Learning COBOL Syntax and Understanding Basic Data Types for Writing Efficient Business Programs


 

1. Introduction: COBOL’s Human-Readable Design

COBOL stands apart from most programming languages because of its English-like syntax. It was intentionally designed to be readable and understandable by people in business, not just programmers. Every COBOL statement ends with a period (.) and often reads like a plain English sentence. This approach made it revolutionary for its time and still contributes to its maintainability today.

For instance, a COBOL instruction like

DISPLAY "HELLO WORLD".

is easy to understand without prior programming experience. COBOL’s syntax encourages clarity, structure, and documentation — key principles in large business systems.


2. Variables and Basic Data Types in COBOL

In COBOL, all variables are defined inside the DATA DIVISION, particularly under the WORKING-STORAGE SECTION. Each variable has a level number and a PICTURE (PIC) clause that describes its data type and format.

Here are a few common examples:

  • PIC X(n): Represents an alphanumeric (string) value of length n.

  • PIC 9(n): Represents a numeric value with n digits.

  • PIC A(n): Represents alphabetic characters only.

For example:

01 STUDENT-NAME PIC X(30). 01 STUDENT-AGE PIC 99.

This structure gives COBOL precise control over data layout — a critical advantage when handling financial or record-based systems.


3. The Power of Structured Data Representation

COBOL’s data representation is hierarchical. You can group related fields using levels like 01, 05, and 10, creating complex record structures that mirror real-world data. This makes COBOL ideal for business logic, where clarity and structure are paramount.

Example:

01 EMPLOYEE-DETAILS. 05 EMP-NAME PIC X(25). 05 EMP-ID PIC 9(5). 05 EMP-SALARY PIC 9(7)V99.

This structured layout makes COBOL programs behave like well-organized databases, reflecting business entities directly in code.


🧠 Key Takeaways

  • COBOL syntax is English-like, structured, and easy to read.

  • Variables are declared in the DATA DIVISION with PIC clauses defining type and size.

  • COBOL’s hierarchical data representation makes it excellent for business data modeling.


💻 Practice Task

  1. Create a new COBOL file called DataTypesDemo.cbl.

  2. Write a simple program that declares and displays variables for a student’s name, age, and grade:

IDENTIFICATION DIVISION. PROGRAM-ID. DATATYPES-DEMO. DATA DIVISION. WORKING-STORAGE SECTION. 01 STUDENT-NAME PIC X(20) VALUE "PRAVEEN". 01 STUDENT-AGE PIC 99 VALUE 21. 01 STUDENT-GRADE PIC A VALUE "A". PROCEDURE DIVISION. DISPLAY "STUDENT DETAILS:". DISPLAY "NAME: " STUDENT-NAME. DISPLAY "AGE: " STUDENT-AGE. DISPLAY "GRADE: " STUDENT-GRADE. STOP RUN.
  1. Save the file — we’ll build on this program tomorrow to include user input and arithmetic operations.

"This Content Sponsored by SBO Digital Marketing.

Mobile-Based Part-Time Job Opportunity by SBO!

Earn money online by doing simple content publishing and sharing tasks. Here's how:

  • Job Type: Mobile-based part-time work
  • Work Involves:
    • Content publishing
    • Content sharing on social media
  • Time Required: As little as 1 hour a day
  • Earnings: ₹300 or more daily
  • Requirements:
    • Active Facebook and Instagram account
    • Basic knowledge of using mobile and social media

For more details:

WhatsApp your Name and Qualification to 9994104160

a.Online Part Time Jobs from Home

b.Work from Home Jobs Without Investment

c.Freelance Jobs Online for Students

d.Mobile Based Online Jobs

e.Daily Payment Online Jobs

Keyword & Tag: #OnlinePartTimeJob #WorkFromHome #EarnMoneyOnline #PartTimeJob #jobs #jobalerts #withoutinvestmentjob"



Comments