Code Monkey home page Code Monkey logo

cobol-ciao's Introduction

COBOL-Ciao

This repo includes several exercises illustrating simple COBOL programs.

Setup

The following instructions are optimized for a Mac user running VS Code.

When opening in VS Code for the first time, install the COBOL Source colouriser extension for easier viewing.

  1. Clone this repo to your local machine.

  2. cd into the cloned repo folder.

  3. From the CLI, run brew install open-cobol.

Exercise: 1

The following program shows you how to print the string, "Ciao!" using COBOL.

  1. The "Ciao!" text can be found in the test.cbl file. cd into the folder where this file is located.

    To compile the test.cbl file into an executable binary, run cobc -free -x -o test test.cbl.

    The -free flag tells GnuCOBOL to be more lenient when parsing code (rather than requiring extremely precise formatting), and the -x flag tells GnuCOBOL to generate an executable file.

  2. Run ls. As you can see, you have a binary executable file called test that you can execute. To do so, run ./test.

    Note: If you cloned this repo, the executable files should already be included. I am adding this step to illustrate how to create an executable in COBOL if you wish to create a new program.

  3. You should now see the text, Ciao! printed in your CLI.

Exercise: 2

The following program shows you how to multiply two single-digit inputs using COBOL.

  1. From the CLI, run cobc -free -x multiply.cbl .

  2. The code with the multiply logic is located in the file multiply.cbl. As in the previous exercise, compile multiply.cbl into an executabe binary file. To do so, run cobc -free -x multiply.cbl .

  3. To run the executable you just created, run ./multiply in the CLI.

  4. When prompted, enter any one-digit number. For this example, 3.

  5. When prompted, enter a second one-digit number. For this example, 7.

  6. You should see the following output: Result is = 21

Sources:
Linux Magazine Tutorial - COBOL
WTF is COBOL?
GnuCOBOL Guides
GnuCOBOL Forum

cobol-ciao's People

Contributors

rebecca-pete avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.