0% found this document useful (0 votes)
35 views

Source Code: #Include #Include #Include

This C++ code defines a library management system with functions for inserting, deleting, viewing, and searching member data stored in an array structure. Member data includes ID, name, address, and phone number. The main function displays a menu and uses switch statements to call the appropriate function based on the user's selection, then repeats the menu until the user chooses to quit. Data is stored in arrays indexed from 0 to a maximum of 99 elements.

Uploaded by

Griko Ilman Syah
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Source Code: #Include #Include #Include

This C++ code defines a library management system with functions for inserting, deleting, viewing, and searching member data stored in an array structure. Member data includes ID, name, address, and phone number. The main function displays a menu and uses switch statements to call the appropriate function based on the user's selection, then repeats the menu until the user chooses to quit. Data is stored in arrays indexed from 0 to a maximum of 99 elements.

Uploaded by

Griko Ilman Syah
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

SOURCE CODE

#include <iostream>
#include <conio.h>
#include <stdio.h>
using namespace std;
int top=0,r=-1,data[100];
struct data
{
int id;
char nm[10];
char almt[10];
int tlp;
}
perpus[20];
void search()

int cari,ketemu;

cout<<"masukan nomer ID member:


";cin>>cari;
ketemu=0;
for (int i=top;i<=r;i++)
{
if(perpus[i].id==cari)
{
ketemu=1;
cout<<"data ditemukan pada
index ke:"<<r<<endl;
cout<<"nama member
"<<perpus[i].nm<<endl;

cout<<"alamat member :
"<<perpus[i].almt<<endl;
cout<<"telepon member :
"<<perpus[i].tlp<<endl;
}

}
if(ketemu==0)
{ cout<<"data tidak ada";}
}
void perpustakaan()
{
system ("cls") ;
cout<<"-------------------"<<endl;
cout<<"Masukan

:"<<endl;

cout<<"-------------------"<<endl;
cout<<"nomor ID member :
";cin>>perpus[r].id;
cout<<"nama member
";cin>>perpus[r].nm;

cout<<"alamat member :
";cin>>perpus[r].almt;

cout<<"telpon member :
";cin>>perpus[r].tlp;
}
void pop_data()
{
top+=1;
cout<<endl<<"Data di
hapus !"<<endl;
}
void view_data()
{
for (int i=top;i<=r;i++)
{
cout<<endl;
cout<<"Data yang telah
dimasukan :"<<endl;

cout<<"nomer ID
"<<perpus[i].id<<endl;

cout<<"nama member :
"<<perpus[i].nm<<endl;
cout<<"alamat member :
"<<perpus[i].almt<<endl;
cout<<"telpon member :
"<<perpus[i].tlp<<endl;
}
}
main()
{
char ul;
int pil;
do
{
system ("cls") ;

cout<<"MENU TAMPILAN"<<endl;
cout<<"\n1. Insert \n2. Delete \n3.
View \n4. Search\n"<<endl;
cout<<"Masukan pilihan : ";
cin>>pil;
switch(pil)
{
case 1 :
r+=1;perpustakaan();
break;
case 2 :
if(top==0&&r==-1){
cout<<"Data
Kosong !"<<endl;}
else{
pop_data();
} break;

case 3 :
if(top==0&&r==-1){
cout<<"Data
Kosong !"<<endl;}
else {view_data();}
break;
case 4 :
if(top==1&&r==-1){
cout<<"Data
Kosong !"<<endl;}
else {search();}
break;
default : cout<<"Pilihan tidak
ada !"<<endl;
break;
}
cout<<endl;

cout<<"Apa ingin mengulang (y/t): ";


cin>>ul;
}
while (ul=='y'||ul=='Y');
getch();
}

You might also like