Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

PROGRAM WHICH SEARCH THE NAME FROM THE FILE AND DISPLAY THE CORRESPONDING ROLL NO OF THE STUDENT

Posted By: Von Fischer     Category: Cobol     Views: 2624

PROGRAM WHICH SEARCH THE NAME FROM THE FILE AND DISPLAY THE CORRESPONDING ROLL NO OF THE STUDENT.

Code for PROGRAM WHICH SEARCH THE NAME FROM THE FILE AND DISPLAY THE CORRESPONDING ROLL NO OF THE STUDENT in Cobol

       IDENTIFICATION DIVISION.
        PROGRAM-ID.search1.

       ENVIRONMENT DIVISION.
        INPUT-OUTPUT SECTION.
         FILE-CONTROL.
          SELECT infile1 ASSIGN TO DISK
          ORGANIZATION IS LINE SEQUENTIAL.

       DATA DIVISION.
        FILE SECTION.
         FD infile1
           VALUE OF FILE-ID IS "search.txt".
          01 in-rec.
            05 ino PIC 99.
            05 iname PIC X(10).

        WORKING-STORAGE SECTION.
          01 tbl.
           05 stu-tbl OCCURS 10 TIMES INDEXED BY idx1.
            10 no1 PIC 99.
            10 name1 PIC X(10).
          01 i PIC 99.
          01 eof PIC X VALUE 'N'.
          01 SNAME PIC X(10).

       PROCEDURE DIVISION.
        PARA1.
            OPEN INPUT infile1.
             READ infile1
              AT END MOVE 'Y' TO eof.
             PERFORM VARYING i FROM 1 BY 1 UNTIL eof='Y'
                MOVE ino TO no1(i)
                MOVE iname TO name1(i)
                READ infile1
                 AT END MOVE 'Y' TO eof
                END-READ
             END-PERFORM.
            CLOSE INFILE1.

            DISPLAY "ENTER THE NAME YOU WANT TO SEARCH".
            ACCEPT SNAME.

            SET idx1 TO 1.
            SEARCH stu-tbl
             AT END DISPLAY "STUDENT NAME NOT FOUND"
             WHEN NAME1(IDX1)=SNAME
               DISPLAY "THE ROLL NO IS " no1(IDX1) " OF " SNAME
            END-SEARCH.
            STOP RUN.


*********************INPUT FILE*****************************
******SEARCH.TXT
******01JOLLY
******02HIMANI
******03ISHA
******04MANALI
******05JANKI
******06HITISHA
******07SARITA
******08KINJAL
******09KHUSHBU
******10JOLLY

*********************OUTPUT*********************************
******ENTER THE NAME YOU WANT TO SEARCH
******JOLLY
******THE ROLL NO IS 01 OF JOLLY

******ENTER THE NAME YOU WANT TO SEARCH
******HITU
******STUDENT NAME NOT FOUND
  
Share: 



Von Fischer
Von Fischer author of PROGRAM WHICH SEARCH THE NAME FROM THE FILE AND DISPLAY THE CORRESPONDING ROLL NO OF THE STUDENT is from Frankfurt, Germany.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!