Cobol Tutorial

 
 
 

Basic Programming

Generate arithmetic operation - evaluate clause

General Programs

Evaluate gender from user and print Display input number is prime or not Display on printer message entered by user Displays message entered by user on printer Merging two files in a single file Read data from input file and move to output file Print account report Use of Sign clause Create attendence sheet Displays on printer - divide operation quotient Binary search on student name, print roll number job appl checking candidate is eligible or not Display the pattern of square School management system

Mathematical Program

Print bill report Purchase and rebate amount payslip Example of string and unstring Describe Functionality of two dimension table Insert, delete, update, view in index file Student details using relative file Converting integer to its number of words Use of move clause for numeric values Use multiple array Inventory transactions Sort records of file Displays alphanumeric char on screen graphic mode Multiplication table Generate sales register

Sorting Programs

Store content in file,record of field - other file Calculate Total percentage Classfor each student Edit character Display pattern of numbers in reverse pattern User input data and stores it in to the file Input record into file using extend mode Draw a line Use of Tables with INPUT clause Check student is pass or fail i/p result from user Calculate monthly sales amount -sequential access Sescribes how to use Sort technique Declares data to the compiler Search name from file display roll no of student Generating julian date

Clause

Describe Functionality of Relative File Print addition of two nos and sum is third or not Use of perform verbs Bank Report depending upon user choice Create result statement for given semester Evaluates arithmetic expression - stores result Use of evaluate clause Describe use of IF CONDITION and PRINT Calculate Total percentage Class for each student Displays alphanumeric character in graphics mode Reads in states until end of data Read student details from file - read operation Merge 2 files with students records Print presence report based on provided data Use of Inspect clause Check entered date is valid birth date or not Draws rectangle filled with one color Search perticular record Find age from accepted date from user Check if a number is a fibonacci or not

File Programs

Check two same condition name is allow or not Arithmetic operations add,sub,div and mul Display on Console a message entered by user Display message entered by user on console Generate student mark sheet using file r/w op Student detail management using indexed file Print mark sheet of a student with grades Use of Redefine clause Create marksheet of student Use of leading and trailing Sequential search Class condition Sum of series 1 + 1/4 + 1/9 Using sign test for numeric value

Search Programs

Enter value is alphabetic,numeric,alphanumeric Find yearly depreciation Unstring word Find smallest quotation for given item Write records reside in i/p file- show on screen Create the index file Draw polygon Use of EVALUATE clause Count number of char Date manipulation Bubble sort DOS standard o/p device Add two numbers Generate sales report item wise

String Programs

Includes external source file in current file Gross salary, deduction, net salary of employee Count character for no of times in input string Display triangle of numbers FILE Read Operation Relative file - insertion,deletion,updation, print Divides one or more operands by another IF-ELSE Clause Group wise stock summary Attendence Report of Employees SORTING Operation Add 2 or more operands and stores result Generating date and time Describe Functionality of table by using File Fahrenheit into temperature - C = (5/9) * (f - 32) Use of Control Break clause Print employee detail Draws an ellipse or a circle Binary search using files
 
 
       IDENTIFICATION DIVISION.
        PROGRAM-ID. STUDENT.

       ENVIRONMENT DIVISION.
        INPUT-OUTPUT SECTION.
        FILE-CONTROL.
         SELECT STU-FILE ASSIGN TO DISK
         ORGANIZATION IS INDEXED
         ACCESS MODE IS RANDOM
         RECORD KEY IS SEM-NO
         ALTERNATE RECORD KEY IS STU-NO.

       DATA DIVISION.
        FILE SECTION.
        FD STU-FILE
          LABEL RECORDS ARE STANDARD
          VALUE OF FILE-ID IS \"STUDENT.MST\".
          01 STU-MST-REC.
           02 SEM-NO     PIC 9.
           02 STU-NO     PIC 99.
           02 STU-NAME   PIC X(20).
           02 GENDER     PIC X.

        WORKING-STORAGE SECTION.
          01 MORE-RECORDS     PIC X VALUE \'Y\'.
          01 DASH-LINE   PIC X(80) VALUE ALL \"=\".
          01 CHOICE1      PIC 9.
          01 EOF PIC X VALUE \"Y\".
      *    01 CH          PIC 9.
          01 WS-STU-REC.
           02 WS-SEM-NO  PIC 9.
           02 WS-STU-NO  PIC 99.
           02 WS-STU-NAME PIC X(20).
           02 WS-GENDER  PIC X.

       PROCEDURE DIVISION.
        MAIN-PARA.
          OPEN I-O STU-FILE
          PERFORM CHOICE-PARA  UNTIL CHOICE1=4
          CLOSE STU-FILE
          STOP RUN.


        CHOICE-PARA.

          DISPLAY DASH-LINE
          DISPLAY \"      STUDENT INFORMATION \".
          DISPLAY DASH-LINE.
          DISPLAY \"1 ) ADD NEW STUDENT\".
          DISPLAY \"2 ) VEW STUDENT RECORD \".
          DISPLAY \"3 ) DELETE STUDENT RECORD\".
          DISPLAY \"4 ) VIEW ALL RECORDS \".
          DISPLAY \"5 ) EXIT \".
          DISPLAY \" ENTER CHOICE \" WITH NO ADVANCING.
          ACCEPT CHOICE1.

          EVALUATE CHOICE1
               WHEN 1 PERFORM ADD-PARA
               WHEN 2 PERFORM VEIW-PARA
               WHEN 3 PERFORM DELETE-PARA
               WHEN 4 PERFORM VEIW-ALL
               WHEN 5 STOP RUN
               WHEN OTHER
                DISPLAY \" INVALID CHOICE \"
          END-EVALUATE.

          ADD-PARA.
             PERFORM UNTIL MORE-RECORDS =\'N\' OR \'n\'
               DISPLAY DASH-LINE
               DISPLAY \"ENTER SEMESTER NO:-\" WITH NO ADVANCING
               ACCEPT WS-SEM-NO
               DISPLAY \"ENTER STUDENT NO :-\" WITH NO ADVANCING
               ACCEPT WS-STU-NO
               DISPLAY \"ENTER STUDENT NAME:-\" WITH NO ADVANCING
               ACCEPT WS-STU-NAME
               DISPLAY \"ENTER GENDER (M/F) :-\" WITH NO ADVANCING
               ACCEPT WS-GENDER

               WRITE STU-MST-REC FROM WS-STU-REC
          DISPLAY \"WANTS TO ENTER RECORDS (Y/N)? :-\"WITH NO ADVANCING
               ACCEPT MORE-RECORDS
               END-PERFORM.


         VEIW-PARA.
               DISPLAY \" ENTER SEMESTER NO :-\"WITH NO ADVANCING.
               ACCEPT WS-SEM-NO.
               DISPLAY \"ENTER STUDENT NO :-\"WITH NO ADVANCING.
               ACCEPT WS-STU-NO.

               MOVE WS-SEM-NO TO SEM-NO.
               MOVE WS-STU-NO TO STU-NO.
                    READ STU-FILE
                         INVALID KEY
                              DISPLAY \"ERROR READING RECORD\"
                         NOT INVALID KEY
                              DISPLAY STU-MST-REC
                    END-READ.

         DELETE-PARA.

               DISPLAY \" ENTER SEMESTER NO :-\" WITH NO ADVANCING.
               ACCEPT SEM-NO.
               DISPLAY \" ENTER STUDENT NO  :-\" WITH NO ADVANCING.
               ACCEPT STU-NO.
        VEIW-ALL.
                   OPEN INPUT STU-FILE
                   PERFORM UNTIL EOF=\"N\"
                   READ STU-FILE 
                      AT END MOVE \"Y\" TO EOF
                      NOT AT END PERFORM V1
                   END-READ
                   END-PERFORM.
          V1.
        DISPLAY STU-MST-REC.
               DELETE STU-FILE 
               INVALID KEY DISPLAY \"RECORD NOT FOUND !\"
               END-DELETE.

INPUT FILE :-
**********************
112123456789012345678901
101AMISH THHCKER       F
102BHAVIKA             F
117HARSHAD GEDIYA      M
111SHASHANK DESAI      M
155HEMAL SHETH         M
129RAJIV MODH          M



OUTPUT :-
*********************
      STUDENT INFORMATION 

1 ) ADD NEW STUDENT
2 ) VEW STUDENT RECORD 
3 ) DELETE STUDENT RECORD
4 ) VEIW ALL RECORDS 
5 ) EXIT 

ENTER CHOICE1 : 1
ENTER SEMISTER NO : 1
ENTER STUDENT NO : 50
ENTER NAME :KHILAN SHAH
ENTER GENDER :M
WNATS TO ENTER RECORDS (Y/N) :N

      STUDENT INFORMATION 

1 ) ADD NEW STUDENT
2 ) VEW STUDENT RECORD 
3 ) DELETE STUDENT RECORD
4 ) VEIW ALL RECORDS 
5 ) EXIT 

ENTER CHOICE1 :2
ENETR SEMISTER NO :1
ENTER STUDENT NO :1
 SEMNO   STU-NO  NAME          GENDER
 1       1      AMISH THHCKER    F

      STUDENT INFORMATION 

1 ) ADD NEW STUDENT
2 ) VEW STUDENT RECORD 
3 ) DELETE STUDENT RECORD
4 ) VEIW ALL RECORDS 
5 ) EXIT 

ENETR CHOICE1:5

 
 
Didn't find what you were looking for? Find more on STUDENT DETAILS MANAGEMENT USING INDEXED FILE