1_what is cobol

Upload: deepalikayande

Post on 30-May-2018

227 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/14/2019 1_What is Cobol

    1/15

    What is COBOL

    Authors:

    Deepali Kayande

    Anuja Jadhav

  • 8/14/2019 1_What is Cobol

    2/15

    Sample Cobol ProgramIDENTIFICATION DIVISION.

    PROGRAM-ID. Multiplier.

    AUTHOR. Abc.

    ENVIRONMENT DIVISION.

    INPUT-OUTPUT SECTION.

    DATA DIVISION.

    WORKING-STORAGE SECTION.

    01 Num1 PIC 9 VALUE ZEROS.

    01 Num2 PIC 9 VALUE ZEROS.

    01 Result PIC 99 VALUE ZEROS.

    PROCEDURE DIVISION.

    DISPLAY "Enter first number (1 digit) : " WITH NO ADVANCING.

    ACCEPT Num1.

    DISPLAY "Enter second number (1 digit) : " WITH NO ADVANCING.

    ACCEPT Num2.

    MULTIPLY Num1 BY Num2 GIVING Result.

    DISPLAY "Result is = ", Result.

    STOP RUN.

  • 8/14/2019 1_What is Cobol

    3/15

    Flow of Cobol Program

    IDENTIFICATION DIVISION.

    ENVIRONMENT DIVISION.

    DATA DIVISION.

    PROCEDURE DIVISION.

  • 8/14/2019 1_What is Cobol

    4/15

    Comparison With Cmain()

    {int i,j,k;printf(Enter a number);scanf(%d, &i);printf(Enter a number);scanf(%d, &j);

    k=i*j;printf(%d ,k);}

    IDENTIFICATION DIVISION.

    PROGRAM-ID. Multiplier.AUTHOR. Abc.

    ENVIRONMENT DIVISION.INPUT-OUTPUT SECTION.

    DATA DIVISION.WORKING-STORAGE SECTION.

    01 Num1 PIC 9 VALUE ZEROS.01 Num2 PIC 9 VALUE ZEROS.01 Result PIC 99 VALUE ZEROS.

    PROCEDURE DIVISION.

    DISPLAY "Enter first number (1 digit) :" WITH NO ADVANCING.ACCEPT Num1.

    DISPLAY "Enter second number(1digit) : WITH NO ADVANCING.ACCEPT Num2.MULTIPLY Num1 BY Num2 GIVING Result.DISPLAY "Result is = ", Result.STOP RUN.

  • 8/14/2019 1_What is Cobol

    5/15

    Cobol Program

    IDENTIFICATIO

    N DIVISION.

    ENVIRONMENT

    DIVISION.DATA DIVISION

    PROCEDURE

    DIVISION.

    FILE

    SECTION

    WORKING-

    STORAGE

    SECTION

    INPUT-

    OUTPUT

    SECTION

    CONFIGURA

    TION

    SECTION

    Para-1.

  • 8/14/2019 1_What is Cobol

    6/15

    What is Cobol

    FORMAT FOR COBOL

  • 8/14/2019 1_What is Cobol

    7/15

    FORMAT FOR COBOLPROGRAMS

    Column

    Field

    1-3 Page Number

    4-6 Line Number (1-6 Sequence Number)

    7 Continuation / Comment

    8-11

    A Margin / Area A

    12-72 B- Margin /Area B

    73-80 Identification

  • 8/14/2019 1_What is Cobol

    8/15

    STRUCTURE OF A COBOLPROGRAM

    Every COBOL program must have the following Four divisions

    in the order in which they are specified below.

    1. Identification division

    2. Environment Division

    3. Data Division

    4. Procedure Division

  • 8/14/2019 1_What is Cobol

    9/15

    Identification division In the Identification division the

    details about the author, date of

    writing the program etc

    Will be specified.Environment Division In the Environment division, the details

    about the computer environment under

    which

    the program was written and compiled

    etc will be notified.

    Data Division In the Data division, the variables that

    are used by the program will be defined

    and it is

    an important division for the program.Procedure Division In the procedure division, all the

    programming statements (Executable

    Cobol statements) will be written and it

    is the most important division.

  • 8/14/2019 1_What is Cobol

    10/15

    CHARACTER SET

    0-9 10 numerals

    A-Z 26 English alphabets-only capitalletters

    minus sign or hyphen

    + Plus sign

    * Asterisk

    / Slash

    0= Equal sign

    $ Currency sign

    , , ; Comma, Semi colon

    Greater than symbol, Less than symbol

    . Period or decimal point

    Quotation mark

    ( ,) Left Parenthesis, Right Parenthesis

  • 8/14/2019 1_What is Cobol

    11/15

    A COBOL word can be formed using the following characters:

    0-9,A-Z (a-z), - (hyphen)

    Rules for Creating Cobol words

    a) A word cannot begin or end with a hyphen.

    b) A word can have at the maximum 30 characters.

    c) One of the characters must be a letter. Some compilers put the additionalrestrictions that the first character must be a letter.

    d) Except hyphen (-) no special character allowed.

  • 8/14/2019 1_What is Cobol

    12/15

    LITERALS

    literal is the specific value which remains

    unchanged throughout the execution of the

    program.There are 3 types of literals

    a) numeric

    b) nonnumeric

    c) figurative constants

  • 8/14/2019 1_What is Cobol

    13/15

    (a) Numeric

    A numeric literal can be formed with the help of digits only

    Examples(i) Valid Numeric Literal (ii) Invalid Numeric

    Literals

    .123 123(valid asnonnumeric literal but

    invalid as numericliteral)

    12.5 - 23 (there is a blankspace between the

    sign and the first digit 2)

  • 8/14/2019 1_What is Cobol

    14/15

    (b) Nonnumeric

    A nonnumeric literal is used in general to output messages orheadings. Characters that are enclosed between constitute nonnumeric literal.

    Ex:- BHARATHIARBHARATHIARDATA DIVISIONDATA DIVISION

    100.50100.50

    HOUR/RATEHOUR/RATE

  • 8/14/2019 1_What is Cobol

    15/15

    c) Figurative Constants

    ZERO ZEROS ZEROESvalue 0

    SPACE SPACES

    One or more blanks

    HIGH-VALUE HIGH-VALUES Highest value in the

    Collating sequence

    LOW-VALUE LOW-VALUES

    Collating sequence

    Lowest value in the

    QUOTE QUOTES

    one or more of

    ALL literal

    One or more of the string Characters

    comprising the literal