Implement a C++ program to develop a simple Library. Library contains pile of books and each book comprises of ISBN (cannot be changed), Name, Author Name, Publisher Name, Issue Date, Return Date. [using Structures]
In C++ a structure is a collection of different data type variables refered under a single name. it is very much similar to a class but it cannot hold the associated functions of the elements/data members in the block so given next to this explaination of structures is the code asked in the question.so its a very basic library system in which you can add a book by using insert function.
#include<iostream.h>
#include<conio.h>
struct book{
char name[50];
int ISBN;
char authorname[50];
char publishername[50];
int issuedate;
int issuemonth;
int issueyear;
int retdate;
int retmonth;
int retyear;
struct book *next=NULL;
}
void insert(struct book *head){
if *head.next==NULL{
struct book node;
cout<<"enter the name of book";
gets(node.name)
cout<<"enter the author name of book";
gets(node.authorname)
cout<<"enter the publisher name of book";
gets(node.publishername)
cout<<"enter isbn no.";
cin>>node.ISBN;
cout<<"enter the issue date month and year";
cin>>node.issuedate;
cin>>node.issuemonth;
cin>>node.issueyear;
cout<<"enter the return date month and year";
cin>>node.retdate;
cin>>node.retmonth;
cin>>node.retyear;
*head.next=&node;
}
else{
insert(*head.next);
}
}
void main(){
//the pile of the books will be stored in a linked list where ISBN no. can be a searching key
struct book library;//first book in library
insert(library);//inserting a book in library
insert(library);//inserting a book in library
getch();
}
*this code may or may not contain bugs.
Get Answers For Free
Most questions answered within 1 hours.