Sabtu, 01 Desember 2012

CONTOH PROGRAM QUEUE PADA BAHASA C


#include "stdio.h"
#include "stdlib.h"
#define MAX 5

int queue[MAX];
int front = -1;
int rear = -1;

main() {
int pil;
clrscr();
while(1){
clrscr();
printf("\n+-------------------+\n");
printf("|       Menu        |\n");
printf("+-------------------+\n");
printf("| 1. Insert Queue   |\n");
printf("| 2. Delete Queue   |\n");
printf("| 3. Display Queue  |\n");
printf("| 4. Exit           |\n");
printf("+-------------------+\n");
printf("Masukkan Pilihan : ");
scanf("%d", &pil);

switch(pil){
case 1 :
clrscr();
insert();
break;
case 2 :
clrscr();
del();
break;
case 3 :
clrscr();
display();
break;
case 4 :
exit(1);
break;
default :
printf("\nInput Salah !"); } } }

insert() {
int add;
clrscr();
if(rear==MAX-1){
printf("Queue Overflow !!!\n");}
else {
if(front==-1)
front = 0;
printf("Masukkan Nilai Elemen Queue : ");
scanf("%d",&add);
rear=rear+1;
queue[rear] = add; } }

del() {
clrscr();
if (front==-1 || front > rear) {
printf("Queue Underflow \n");
return;
} else {
printf("Element Queue yang di Delete adalah : %d \n", queue[front]);
front=front+1;
getch(); } }

display() {
int i;
clrscr();
if (front == -1){
printf("Queue kosong\n");
}else {
printf("Nilai Element Queue Adalah : \n");
for(i=front;i<=rear;i++){
printf("%d",queue[i]);
printf(" ");} }
getch(); }

Kalo ingin melihat output programnya klik disini.

CONTOH PROGRAM INFIX TO POSTFIX PADA BAHASA C


#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<math.h>

#define oper(x) (x=='+' || x=='-' || x=='*' || x=='/')

char in[30], post[30], stack[30];
int top=-1;

void push(char x)
{
stack[++top]=x;
}

char pop()
{
    return stack[top--];
}

int precedence(char c)
{
 if (c=='+' || c=='-')
return 1;
   if (c=='*' || c=='/')
return 2;
   if (c=='(')
return 3;
}

main()
{
   char c;
   int l,i,j=0,st1[20],k,h,f,eval,s,N;

   clrscr();
   printf("Masukkan notasi infix : ");
   scanf("%s",&in);
   l=strlen(in);

   for(i=0;i<=l;i++)
   {
if(oper(in[i]))
{
   post[j++]=' ';
   while(precedence(in[i])<precedence(stack[top])) //any problem here?
   {
post[j++]=stack[top];
pop();
post[j++]=' ';

   }
   push(in[i]);
}
else if(in[i]=='\0')
{
   while(top!=-1)
   {
post[j++]=' ';
post[j++]=stack[top];
pop();
   }
}
else
   post[j++]=in[i];
   }
   post[j]='\0';
   printf("Hasil notasi postfix : %s\n",post);
   i=0;top=-1;f=0;k=0;
   while(i<j)
   {
if(oper(post[i]))
{
   f=1;
   c=post[i];
   eval=0;
   switch(c)
   {
   case '+':
eval=st1[top-1]+st1[top];
break;
   case '-':
eval=st1[top-1]-st1[top];
break;
   case '*':
eval=st1[top-1]*st1[top];
break;
   case '/':
eval=st1[top-1]/st1[top];
break;
   }
   top--;
   st1[top]=eval;
}
else if(post[i]==' ')
{
   if(f==0)
   {
h=i-k;
s=0;
while(post[h]!=' ')
{
   N=(int)post[h];
   N=N-48;
   s=s+N*(pow(10,(k-1)));
   k--;
   h++;
}
st1[++top]=s;
   }
   k=0;
}
else
{
   k++;
   f=0;
}
i++;
   }
   printf("Hasil operasi perhitungan : %d\n",st1[top]);
getch();
return 0;}

kalo ingin meliat output programnya klik disini.

CONTOH PROGRAM NODE PADA BAHASA C


#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
#define N 100

struct dclinklist{
    struct dclinklist *prev;          /** Stores address of previous node **/
    int roll_no;                       /** stores roll number **/
    char name[N];                     /** stores Name **/
    float marks;                      /** stores Marks **/
    struct dclinklist *next;         /** stores address of next node **/
};

/** Redefining dclinklist as node **/
typedef struct dclinklist node;

void init(node*);     /** Input function **/
void ins_aft(node*);  /** Function inserting before **/
node* ins_bef(node*); /** Function inserting after **/
node* del(node*);     /** Function deleting a node **/
void search(node*);   /** Function for searching node **/
void disp(node*);     /** Function for displaying node **/
void rollsrch(node*); /** Function for searching node by roll number **/
void namesrch(node*); /** Function for searching node by name **/
void marksrch(node*); /** Function for searching node by marks **/

/*** Main Function ***/
void main(){
    node *head;
    char ch;                  /* Choice inputing varible */
    int opt;                  /* Option inputing variable*/
    static int flag=0;        /* Unchanged after iniialization */
    clrscr();
    head=(node*)malloc(sizeof(node));
    head->next=NULL; /* NULL is being over written in init function */
    head->prev=NULL;
    do{
    again:
            printf("\nInput pilihan\n");
            printf("\n1. Inisialisasi node\n");      
            printf("\n2. Insert sebelum spesifik node\n");
            printf("\n3. Insert setelah spesifik node\n");
            printf("\n4. Delete node \n");
            printf("\n5. Search Node\n");
            printf("\n6. Display Semua node\n");
            scanf("%d",&opt);
    if(flag==0 && opt!=1){
        printf("\nHarus Inisialisasi Node terlebih dahulu sebelum input!\n");
        goto again;
    }
    if(flag==1 && opt==1){
        printf("\nInisialiasi cuma bisa dilakukan sekali!\n");
        printf("\nInput sebuah node sekarang\n");
        goto again;
    }
    if(opt==4 && head->next==head){
        printf("\nProses penghapusan tidak boleh dilakukan, jika node hanya terdiri dari 1!\n");
        goto again;
    }
    if(flag==0 && opt==1)
        flag=1;
    switch(opt){
    case 1:
        init(head);
        break;
    case 2:
        head=ins_bef(head);
        break;
    case 3:
        ins_aft(head);
        break;
    case 4:
        head=del(head);
        break;
    case 5:
        search(head);
        break;
    case 6:
        disp(head);
        break;
    default:
    break;
    }
    printf("\nMasih mau melanjutkan proses![y/n]\n");
    ch=(char)getche();
    }while(ch=='Y' || ch=='y');
    printf("\nDone by \"LAB TI Univ-Gunadarma J1\"\n");
    printf("\nPress any key to exit\n");
    getch();
}

/*** Function for inputing data ***/
void init(node *start){
    start->prev=start;
    printf("\nMasukkan Roll number\n");
    scanf("%d",&start->roll_no);
    printf("\nMasukkan nama\n");
    fflush(stdin);
    gets(start->name);
    printf("\nMasukkan Tanda\n");
    scanf("%f",&start->marks);
    start->next=start;
}

/*** Function for inserting a node after a specified node ***/
void ins_aft(node *start){
    int rno;                  /* Roll number for inserting a node */
    int flag=0;
    node *newnode;            /* New inputed node*/
    node *current;            /* Node for travelling the linked list*/
    newnode=(node*)malloc(sizeof(node));
    printf("\nMasukkan setelah Roll Number berapa kamu mau menyisipkan!\n");
    scanf("%d",&rno);
    init(newnode);
    current=start;
    while(current->next!=start){
        /***  Insertion checking for all nodes except last  ***/
        if(current->roll_no==rno){
            newnode->next=current->next;
            current->next->prev=newnode;
            current->next=newnode;
            newnode->prev=current;
            flag=1;
        }
        current=current->next;
    }
    if(flag==0 && current->next==start && current->roll_no==rno){
        /***  Insertion checking for last node  ***/
        newnode->next=current->next;     /* Start is being copied */
        current->next->prev=newnode;
        current->next=newnode;
        newnode->prev=current;
        flag=1;
    }
    if(flag==0 && current->next==NULL)
        printf("\nNo match found\n");
}

/*** Function for inserting a node before a specified node ***/
node* ins_bef(node *start){
    int rno;                  /* Roll number for inserting a node*/
    node *newnode;            /* New inputed node */
    node *current;            /* Node for travelling the linked list*/
    newnode=(node*)malloc(sizeof(node));
    printf("\nMasukkan sebelum Roll Number berapa kamu  mau menyisipkan!\n");
    scanf("%d",&rno);
    init(newnode);
    current=start;
    if(current->roll_no==rno){
        /*** Insertion checking for first node ***/
        newnode->next=current;
        current->prev=newnode;
        while(current->next!=start)
            current=current->next;
        newnode->prev=current;
        current->next=newnode;
        start=newnode;
        return(start);
    }
    while(current->next!=start){
        /*** Insertion checking for all node except first ***/
        if(current->next->roll_no==rno){
            newnode->next=current->next;
            current->next->prev=newnode;
            current->next=newnode;
            newnode->prev=current;
            return(start);
        }
        current=current->next;
    }
    /*If the function does not return from any return statement.There is no match to insert before the input  roll number. */
    printf("\nMatch not found\n");
    return(start);
}

/*** Function for deleting ***/
node* del(node *start){
    int rno;                  /* Roll number for deleting a node*/
    node *delnode;            /* Node to be deleted */
    node *current;            /* Node for travelling the linked list*/
    printf("\nEnter the roll number whose node you want to delete\n");
    scanf("%d",&rno);
    current=start;
    if(current->roll_no==rno) {
        /***  Checking condition for deletion of first node  ***/
        delnode=current; /*  Unnecessary step  */
        while(current->next!=start)
        current=current->next;
        current->next=start->next;
        start->next->prev=current;
        start=start->next;
        free(delnode);
        return(start);
    }
    else{
        while(current->next->next!=start){
            /***  Checking condition for deletion of   ***/
            /*** all nodes except first and last node  ***/
            if(current->next->roll_no==rno){
                delnode=current->next;
                current->next=current->next->next;
                current->next->prev=current;
                free(delnode);
                return(start);
            }
            current=current->next;
        }
        if(current->next->next==start && current->next->roll_no==rno){
            /***  Checking condition for deletion of last node  ***/
            delnode=current->next;
            free(delnode);
            current->next=start;
            return(start);
        }}
    printf("\nMatch not found\n");
    return(start);
}

/*** Function for searching ***/
void search(node *start){
    int ch;                   /* Choice inputing variable */
    printf("\nPencarian Berdasarkan kriteria\n");
    printf("\n1. Roll number\n");
    printf("\n2. Nama\n");
    printf("\n3. Tanda\n");
    scanf("%d",&ch);
    switch(ch){
    case 1:
        rollsrch(start);
        break;
    case 2:
        namesrch(start);
        break;
    case 3:
        marksrch(start);
        break;
    default:
        rollsrch(start);
    }}

/*** Function for searching ***/
void rollsrch(node *start){
    int rno;                  /* Roll-number to be searched */
    node *current;            /* Node for travelling the linked list*/
    printf("\nMasukkan Roll Number berapa yang mau dicari!\n");
    scanf("%d",&rno);
    current=start;
    while(current->next!=start){
        if(current->roll_no==rno)
            printf("\n%d\t%s\t%f\n",current->roll_no,current->name,current->marks);
        current=current->next;
    }
        if(current->next==start && current->roll_no==rno)
        printf("\n%d\t%s\t%f\n",current->roll_no,current->name,current->marks);
}

/*** Function for searching ***/
void namesrch(node *start){
    char arr[20];             /* Name to be searched*/
    node *current;            /* Node for travelling the linked list*/
    printf("\nInput nama yang mau di cari!\n");
    fflush(stdin);
    gets(arr);
    current=start;
    while(current->next!=start){
        if(strcmp(current->name,arr)==NULL)
            printf("\n%d\t%s\t%f\n",current->roll_no,current->name,current->marks);
        current=current->next;
    }
    if(current->next==start && strcmp(current->name,arr)==NULL)
        printf("\n%d\t%s\t%f\n",current->roll_no,current->name,current->marks);
}
/*** Function for searching ***/
void marksrch(node *start){
    float marks;              /* Marks to be searched */
    node *current;            /* Node for travelling the linked list*/
    printf("\nInput tanda yang mau dicari!\n");
    scanf("%f",&marks);
    current=start;
    while(current->next!=start){
        if(current->marks==marks)
            printf("\n%d\t%s\t%f\n",current->roll_no,current->name,current->marks);
        current=current->next;
    }
    if(current->next==start && current->marks==marks)
        printf("\n%d\t%s\t%f\n",current->roll_no,current->name,current->marks);
}
/*** Function for displaying the linked list ***/
void disp(node *start){
    node *current;            /* Node for travelling the linked list*/
    current=start;
    while(current->next!=start) {
        printf("\n %d  %s  %f",current->roll_no,current->name,current->marks);
        current=current->next;
    }
    printf("\n %d  %s  %f",current->roll_no,current->name,current->marks);
}


kalo mau lihat output programnya klik disini.

CONTOH PROGRAM POINTER PADA BAHASA C


#include <stdio.h>
#include <conio.h>
void main()
{
int nilai1,nilai2,nilai3,*penunjuk,*penunjuk1,*penunjuk2;

nilai1 = 123;
nilai2 = 345;
nilai3 = 678;

clrscr();
penunjuk = &nilai1;
penunjuk1 = &nilai2;
penunjuk2 = &nilai3;

printf("Nilai %d di alamat memory %p \n",*penunjuk,penunjuk);
printf("Nilai %d di alamat memory %p \n",*(penunjuk1),penunjuk+1);
printf("Nilai %d di alamat memory %p \n",*(penunjuk2),penunjuk+2);

getch();
clrscr();
}

jika ingin melihat outputnya, klik disini.

CONTOH PROGRAM MATRIKS PADA COBOL


        IDENTIFICATION DIVISION.
        PROGRAM-ID. MATRIKS.
        ENVIRONMENT DIVISION.
        DATA DIVISION.
        WORKING-STORAGE SECTION.
77 A PIC 9.
        77 I PIC 99.
        77 J PIC 99.
        01 CETAK.
            02 M1 PIC Z9.
            02 M2 PIC Z9.
            02 T PIC Z9.
        01 TOTAL.
            02 TOTAL-BARIS OCCURS 2 TIMES.
              03 TM OCCURS 2 TIMES PIC 999.
        01 DATA1.
            02 BARIS1 OCCURS 2 TIMES.
                03 MATRIK1 OCCURS 2 TIMES PIC 99.
        01 DATA2.
            02 BARIS2 OCCURS 2 TIMES.
                03 MATRIK2 OCCURS 2 TIMES PIC 99.
01 ISI-LAGI PIC X.
            88 LAGI VALUE 'Y' , 'y'.
   88 TIDAK VALUE 'T' , 't'.
        SCREEN SECTION.
        01 HAPUS-LAYAR.
            02 BLANK SCREEN.
        01 TAMBAH.
            02 LINE 3 COLUMN 16 VALUE '+' HIGHLIGHT.
            02 LINE 3 COLUMN 31 VALUE '=' HIGHLIGHT.
        01 KURANG.
            02 LINE 3 COLUMN 16 VALUE '-' HIGHLIGHT.
            02 LINE 3 COLUMN 31 VALUE '=' HIGHLIGHT.
        01 KALI.
            02 LINE 3 COLUMN 16 VALUE '*' HIGHLIGHT.
            02 LINE 3 COLUMN 31 VALUE '=' HIGHLIGHT.
        PROCEDURE DIVISION.
        MULAI.
   DISPLAY HAPUS-LAYAR.
            DISPLAY '=====MENU MATRIKS====='.
   DISPLAY '1.PERTAMBAHAN'.
   DISPLAY '2.PENGURANGAN'.
   DISPLAY '3.PERKALIAN'.
   DISPLAY '4.EXIT'.
   DISPLAY 'MASUKKAN ANGKA [1-4] :'.
            ACCEPT A.
   IF A = 4 GO TO SELESAI.
REDI.
   MOVE 3 TO LIN.
            DISPLAY HAPUS-LAYAR.
            PERFORM CARA1
                VARYING I FROM 1 BY 1 UNTIL I > 2
                AFTER J FROM 1 BY 1 UNTIL J > 2
            COMPUTE LIN = 10.
            PERFORM CARA2
                VARYING I FROM 1 BY 1 UNTIL I > 2
                AFTER J FROM 1 BY 1 UNTIL J > 2
   IF A = 1 GO TO ASU.
   IF A = 2 GO TO MINUS.
   IF A = 3 GO TO BINTANG.
ASU.
   PERFORM PROSESPLUS
VARYING I FROM 1 BY 1 UNTIL I > 2
AFTER J FROM 1 BY 1 UNTIL J > 2
   DISPLAY HAPUS-LAYAR.
            DISPLAY TAMBAH.
   PERFORM HASIL
VARYING I FROM 1 BY 1 UNTIL I > 2
AFTER J FROM 1 BY 1 UNTIL J > 2
   DISPLAY ' '.
           DISPLAY 'TAMBAH LAGI [Y/T] :'.
            ACCEPT ISI-LAGI.
         IF LAGI GO TO MULAI.
   IF TIDAK GO TO SELESAI.
MINUS.
   PERFORM PROSESMINUS
VARYING I FROM 1 BY 1 UNTIL I > 2
                AFTER J FROM 1 BY 1 UNTIL J > 2
   DISPLAY HAPUS-LAYAR.
            DISPLAY KURANG.
   PERFORM HASIL
VARYING I FROM 1 BY 1 UNTIL I > 2
AFTER J FROM 1 BY 1 UNTIL J > 2
   DISPLAY ' '.
     DISPLAY 'KURANG LAGI [Y/T] :'.
            ACCEPT ISI-LAGI.
   IF LAGI GO TO MULAI.
   IF TIDAK GO TO SELESAI.
BINTANG.
   PERFORM PROSESKA
VARYING I FROM 1 BY 1 UNTIL I > 2
AFTER J FROM 1 BY 1 UNTIL J > 2
   DISPLAY HAPUS-LAYAR.
            DISPLAY KALI.
   PERFORM HASIL
VARYING I FROM 1 BY 1 UNTIL I > 2
AFTER J FROM 1 BY 1 UNTIL J > 2
   DISPLAY ' '.
   DISPLAY 'KALI LAGI [Y/T] :'.
            ACCEPT ISI-LAGI.
   IF LAGI GO TO MULAI.
   IF TIDAK GO TO SELESAI.
CARA1.
     DISPLAY (3, 2) 'MATRIK 1'.
            COMPUTE LIN = LIN + 1.
            DISPLAY (LIN, 2) 'ELEMEN [', I, ', ', J, '] = '.  
   ACCEPT MATRIK1 (I, J).
        CARA2.
            DISPLAY (10, 2) 'MATRIK 2'.
            COMPUTE LIN = LIN + 1.
            DISPLAY (LIN, 2) 'ELEMEN [', I, ', ', J, '] = '.
            ACCEPT MATRIK2 (I, J).
        PROSESPLUS.
   COMPUTE TM (I, J) = MATRIK1 (I, J) + MATRIK2 (I, J).
        PROSESMINUS.
   COMPUTE TM (I, J) = MATRIK1 (I, J) - MATRIK2 (I, J).
        PROSESKA.
            COMPUTE TM ( 1 , 1 ) = MATRIK1 ( 1 , 1 ) * MATRIK2 ( 1 , 1 )
            + MATRIK1 ( 1 , 2 ) * MATRIK2 ( 2 , 1 ).
            COMPUTE TM ( 1 , 2 ) = MATRIK1 ( 1 , 1 ) * MATRIK2 ( 1 , 2 )
            + MATRIK1 ( 1 , 2 ) * MATRIK2 ( 2 , 2 ).
            COMPUTE TM ( 2 , 1 ) = MATRIK1 ( 2 , 1 ) * MATRIK2 ( 1 , 1 )
            + MATRIK1 ( 2 , 2 ) * MATRIK2 ( 2 , 1 ).
            COMPUTE TM ( 2 , 2 ) = MATRIK1 ( 2 , 1 ) * MATRIK2 ( 1 , 2 )
            + MATRIK1 ( 2 , 2 ) * MATRIK2 ( 2 , 2 ).
        HASIL.
            MOVE I TO LIN.
            MOVE J TO COL.
            MOVE MATRIK1 (I, J) TO M1.
            MOVE MATRIK2 (I, J) TO M2.
            MOVE TM (I, J) TO T.
            COMPUTE LIN = LIN * 2.
            COMPUTE COL = COL * 4.
            DISPLAY (LIN, COL + 1) M1.
            DISPLAY (LIN, COL + 16) M2.
            DISPLAY (LIN, COL + 31) T.
SELESAI.
   DISPLAY 'MAACIH KAKAK..'.
   STOP RUN.

CONTOH PROGRAM FILE PADA COBOL


       IDENTIFICATION DIVISION.
       PROGRAM-ID. RELATIF.
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT MHS ASSIGN TO DISK
           ORGANIZATION IS RELATIVE
           ACCESS MODE IS DYNAMIC
           RELATIVE  KEY IS NO-REL
           FILE STATUS IS STATUS-SALAH.
       DATA DIVISION.
       FILE SECTION
       FD  MHS
           LABEL RECORD IS STANDARD
           VALUE OF FILE-ID IS 'MHS.DAT'
           DATA RECORD IS RECMHS.
       01  RECMHS.
           02 NPM PIC 9(8).
           02 NAMA PIC X(20).
           02 KELAS PIC X(5).
       WORKING-STORAGE SECTION.
       01  JUDUL.
           02 WS-NAMA PIC X(25).
           02 WS-NPM PIC 9(8).
           02 WS-KELAS PIC X(8).
           02 NPM-CARI PIC 9(8).
       01  TAMBAH-DATA PIC X.
           88 LAGI VALUE 'Y', 'y'.
           88 TDK VALUE 'T', 't'.
       01  X PIC 9 VALUE 0.
       77  STATUS-SALAH PIC XX.
       77  NO-REL PIC 9(8).
       77  PIL PIC X.
       77  PIL2 PIC X.
       77  PIL3 PIC X.
       77  CR-NPMX PIC X VALUE 'Y'.

       SCREEN SECTION.
       01  HAPUS.
           02 BLANK SCREEN.
       01  MASUKAN.
           02 LINE 5 COLUMN 24 VALUE 'NPM   : '.          
  02 COLUMN PLUS 2 PIC  X(8) TO NPM.
           02 LINE 7 COLUMN 24 VALUE 'NAMA  : '.
           02 COLUMN PLUS 2 PIC X(20) TO NAMA.
           02 LINE 9 COLUMN 24 VALUE 'KELAS : '.
           02 COLUMN PLUS 2 PIC X(5) TO KELAS.
       01  MENU.
           02 LINE 5 COLUMN 27 '<< MENU >>'.
           02 LINE PLUS 2 COLUMN 21 '[1] BUAT / INPUT FILE'.
           02 LINE PLUS 1 COLUMN 21 '[2] TAMPIL FILE'.
           02 LINE PLUS 1 COLUMN 21 '[3] CARI DATA '.
           02 LINE PLUS 1 COLUMN 21 '[4] EXIT '.
           02 LINE PLUS 2 COLUMN 21 'PILIH : '.
           02 COLUMN PLUS 1 PIC X TO PIL.
       01  CARI-X.
           02 BLANK SCREEN.
           02 LINE 5 COLUMN 25 'NPM YANG DICARI : '.
           02 COLUMN PLUS 1 PIC X(8) TO NPM-CARI.

       PROCEDURE DIVISION.
       PROGRAM-UTAMA.
           COMPUTE X = 0.
           DISPLAY HAPUS.
           DISPLAY MENU.
           ACCEPT MENU.
           IF PIL = '1' GO TO BUKA.
           IF PIL = '2' GO TO TAMPIL.
           IF PIL = '3' GO TO CARI.
           IF PIL = '4' GO TO SELESAI.
       BUKA.
           OPEN OUTPUT MHS.
           GO TO BUKA2.
       BUKA2.
           DISPLAY HAPUS.
           DISPLAY MASUKAN.
           ACCEPT MASUKAN.
           COMPUTE NO-REL = NPM.
           WRITE RECMHS.
           DISPLAY (15, 23) 'MAU NAMBAH DATA [Y/T] ? '
           ACCEPT TAMBAH-DATA.
           IF LAGI GO TO BUKA2.
           CLOSE MHS.
           GO TO PROGRAM-UTAMA.
       TAMPIL.
           DISPLAY HAPUS.
           DISPLAY (1, 1) 'NAMA'.
           DISPLAY (1, 22) 'NPM'.
           DISPLAY (1, 32) 'KELAS'.
           OPEN INPUT MHS.
           COMPUTE X = 1.
           GO TO TAMPIL3.
     
       TAMPIL3.
           COMPUTE X = X + 1.
           MOVE X TO LIN.
           READ MHS NEXT RECORD AT END GO TO TAMPIL4.
           MOVE NAMA TO WS-NAMA.
           MOVE NPM TO WS-NPM.
           MOVE KELAS TO WS-KELAS.
           DISPLAY (LIN, 1) WS-NAMA.
           DISPLAY (LIN, 22) WS-NPM.
           DISPLAY (LIN, 32) WS-KELAS.
         
       TAMPIL4.
           ACCEPT PIL.
           CLOSE MHS.
           GO TO PROGRAM-UTAMA.
       CARI.
           MOVE 'N' TO CR-NPMX.
           DISPLAY CARI-X.
           ACCEPT CARI-X.
           OPEN INPUT MHS.
           GO TO CARI2.
       CARI2.
           READ MHS NEXT AT END GO TO CARI3.
           MOVE NAMA TO WS-NAMA.
           MOVE NPM TO WS-NPM.
           MOVE KELAS TO WS-KELAS.
           IF NPM-CARI = WS-NPM GO TO KETEMU.
           GO TO CARI2.
       KETEMU.
           DISPLAY HAPUS.
           DISPLAY (7, 23) 'DATA NPM : ' WS-NPM.
           DISPLAY (9, 23) 'NAMA     : ' WS-NAMA.
           DISPLAY (11, 23) 'KELAS    : ' WS-KELAS.
           DISPLAY (15, 23) 'CARI DATA LAGI ? '.
           ACCEPT ( , ) PIL2.
           CLOSE MHS.
           IF PIL2 = 'Y' OR PIL2 = 'y' GO TO CARI.
           GO TO PROGRAM-UTAMA.
       CARI3.
           DISPLAY HAPUS.
           DISPLAY 'DATA TIDAK ADA...'.
           DISPLAY 'Press Escape / Enter Untuk Cari Lagi..'.
           DISPLAY 'X Untuk Ke Menu Utama, Lalu Tekan Enter..'.
           ACCEPT ( , ) PIL3.
           CLOSE MHS
           IF PIL3 = 'X' OR PIL3 = 'x' GO TO PROGRAM-UTAMA.
           GO TO CARI.

       SELESAI.
           DISPLAY HAPUS.
           DISPLAY (2, 2) 'Good Bye......'.
           CLOSE MHS.
           STOP RUN.