-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBooksLibrary.cpp
51 lines (45 loc) · 1.11 KB
/
BooksLibrary.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include<iostream>
using namespace std;
// struct book
// {
// string tittle;
// string author;
// string subject;
// int id;
// };
struct book
{
string tittle;
string author;
string subject;
int id;
};
int main()
{
//Number of books you want to enter data for;
int number_of_books;
cout<<"Enter the number of books you want ot enter details for :";
cin>>number_of_books;
struct book s[number_of_books];
//Taking inputs from the user for book details
for(int i=0;i<number_of_books;i++)
{
cout<<"Enter tittle of the book:";
cin>>s[i].tittle;
cout<<"Enter name of author :";
cin>>s[i].author;
cout<<"Enter subject of the book :";
cin>>s[i].subject;
cout<<"Enter Book Id :";
cin>>s[i].id;
}
//Displaying the details of the book from an array of structure
for(int i=0;i<number_of_books;i++)
{
cout<<"Tittle:"<<s[i].tittle<<endl;
cout<<"Author:"<<s[i].author<<endl;
cout<<"Subject:"<<s[i].subject<<endl;
cout<<"Book Id:"<<s[i].id<<endl;
}
return 0;
}