Logo

dev-resources.site

for different kinds of informations.

COBOL Tutorial Series: A calculation program - Session 2

Published at
10/19/2024
Categories
development
cobol
banking
Author
ngtduc693
Categories
3 categories in total
development
open
cobol
open
banking
open
Author
9 person written this
ngtduc693
open
COBOL Tutorial Series: A calculation program - Session 2

Hello. I'm Duke

In the previous article, I showed you how to program and compile COBOL applications on Windows 11 without a mainframe computer through WSL (Debian) and Visual Studio Code.

Now, I will guide you how to write a very simple calculation program, allowing you to calculate the sum of 2 numbers entered from the keyboard.

First, create the calculate.cbi file

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SimpleAddition.

       DATA DIVISION.          
       WORKING-STORAGE SECTION.
       01  Number1    PIC 9(4).
       01  Number2    PIC 9(4).
       01  Result     PIC 9(4).

       PROCEDURE DIVISION.     
       Main-Process.           
           DISPLAY "Enter first number (0-9999): "
           ACCEPT Number1      
           DISPLAY "Enter second number (0-9999): "
           ACCEPT Number2      

           COMPUTE Result = Number1 + Number2
           DISPLAY "The sum of " Number1 " and " Number2 " is " Result
           STOP RUN.
Enter fullscreen mode Exit fullscreen mode

calculate.cbi

Then, run the following commands:

cobc -x calculate.cbl
./calculate
Enter fullscreen mode Exit fullscreen mode

and here is the result

result

Some notes:

PIC 9(4) means:

  • 9: indicates that the variable will contain digits (0-9).
  • (4): specifies that the variable can contain up to 4 digits.

Repository here

banking Article's
30 articles in total
Favicon
Is it easy to manage a team of highly qualified engineers?
Favicon
Advantages of Open Banking on Retail Investment
Favicon
Open Banking: Revolutionising the future of financial services
Favicon
Understanding PostgreSQL Isolation Levels
Favicon
How Virtual CFO Services Empower Small and Medium Enterprises (SMEs)
Favicon
How to Secure Your Cash App Account After Buying
Favicon
Buy Verified Cashapp and Streamline Your Workflow
Favicon
SEOSiri | AI-Powered Finance: A Strategic Playbook for EU Financial Service Providers
Favicon
Embracing the Cloud for Banking Innovation
Favicon
Effective Logging with ILogger in USSD Banking Applications: A .NET Approach
Favicon
AI in Finance: Transforming Banking and Investment
Favicon
Streamlining Compliance and Risk Management in Banking through RPA
Favicon
Embarking on the Digital Frontier: Decoding the World of Banking Applications
Favicon
Cloud Computing in Banking: Enhancing Efficiency and Security
Favicon
RPA Implementation Services for Banking: Essential Insights for 2024
Favicon
Data Engineering in Observability: The Backbone of Modern Monitoring
Favicon
Investment Banking in Emerging Markets: Opportunities and Challenges
Favicon
Innovation Unleashed: The Crucial Role of Banking Software Development
Favicon
COBOL Tutorial Series: Condition (IF, ELSE) statement - Session 3
Favicon
COBOL Tutorial Series: A calculation program - Session 2
Favicon
COBOL Tutorial Series: Loop statements - Session 4
Favicon
COBOL Tutorial Series: Developing Without a Mainframe - Session 1
Favicon
Mastering Equity Research Industry Analysis and Company Valuation
Favicon
Investment Banking Automation: Transforming the Future of Finance
Favicon
Mobile Banking App Development Costs - AI and Blockchain
Favicon
The Future of Banking: How Video KYC is Transforming Customer Onboarding
Favicon
What Are API Banking Services and How Can They Benefit You?
Favicon
Recurring Payments Simplified: How Flutterwave Static Virtual Accounts Can Transform Your Business
Favicon
How to Find and Hire the Best Fintech Developer
Favicon
Importance of Offshoring in Investment Banking

Featured ones: