WritMy program shows function declared as void .The program is about library system . User can enter books ,cost and auther name and book id and after entring data it displays it on the secreen.The structure takes input but does not display the entered records .pLease help me .
#include<iostream>
#include<string>
usingnamespace std;
struct book
{
char book_name[50];
char book_auth[50];
int Book_ID;
int Cost_Book;
};
void search();
void dis_books();
void add_books();
void choice();
void mnu();
void dis_books(b1[no_books]);
void cont();//continue of exit the program
char yorn;
void dis_books(b1[no_books]){
cout<<"The details of the Books are given below"<<endl;
for(int i=0;i<=5;i++){
cout<<"Book id"<<"="<<b1[i].Book_ID<<endl;
cout<<"Book name is"<<"="<<b1[i].book_name<<endl;
cout<<"Book auther is"<<"="<<b1[i].book_auth<<endl;
}
}
void choice(){
int choice;
mnu();
cin>>choice;
do{
switch(choice){
case 1:
add_books();
cout<<"Press y/n to continue"<<endl;
cin>>yorn;
if(yorn=='y'){
mnu();
cin>>choice;
}
break;
case(2):
book b3[2];
dis_books();
cout<<"Press y/n to continue"<<endl;
cin>>yorn;
if(yorn=='y'){
mnu();
cin>>choice;
}
break;
default:
mnu();
cin>>choice;
cout<<"Press y/n to continue"<<endl;
cin>>yorn;
}
if(choice!=1|choice!=2|choice!=3|choice!=4|choice!=5){
cout<<"Please make your choice"<<endl;
mnu();
cin>>choice;
}
}
while(yorn=='y');
}
void add_books(){
int no_books;
int id;
cout<<"Please enter number of books"<<endl;
cin>>no_books;
cout<<"::Lets adding records::"<<endl;
for(int i=0;i<=0;i++){
cout<<"The book id is"<<"="<<i+1<<endl;
b1[i]. Book_ID=i+1;
cout<<"Please enter book name"<<endl;
//cin.ignore();
cin.getline(b1[i].book_name,50);
cout<<"Please enter auther name"<<endl;
cin.getline(b1[i].book_auth,50);
cout<<"Please enter the cost of the book"<<endl;
cin>>b1[i].Cost_Book;
}
}
void mnu(){//function for displaying menu
cout<<"---------------------------Library Management System-------------------------------"<<endl;
cout<<"Library Management system"<<endl;
cout<<"Press 1 To Enter a Book Record"<<endl;
cout<<"Press 2 To Display all Records of Books Available in Library"<<endl;
cout<<"Press 3 To Search Books by Author Name."<<endl;
cout<<"Press 4 To Count Total Books in Library"<<endl;
cout<<"Press 5 To Exit from the System"<<endl;
}
int main(){
choice();
// book b3[2];
// for (int i=0;i<2;i++){
// cout<<"Please enter book name"<<endl;
// cin>>b3[i].book_name;
// cout<<"Please enter cost"<<endl;
// cin>>b3[i].Cost_Book;
// cout<<"Please enter auther"<<endl;
// cin>>b3[i].book_auth;
//
// }
//
// for (int i=0;i<=1;i++){
// cout<<" book name"<<endl;
// cout<<b3[i].book_name;
// cout<<" cost"<<endl;
// cout<<b3[i].Cost_Book<<endl;
// cout<<" auther"<<endl;
// cout<<b3[i].book_auth<<endl;
//
// }
//
getche();
}
here.
Also, at line 75, an | is the bitwise OR-operator. If you want to check if neither of your numbers where be entered, you need to write: if( choice!=1 && choice!=2 &&...