Define a structure to store the record of library. The
record must consist of at least following fields: Title,
Author, Edition, Price, Publisher, and Category.
-Define functions authorSearch ( ), TitleSearch ( ) and
CategorySearch ( ) to search a book with respect to author,
title and category. [There can be more than one book,
written by one author, in one category]
Answers were Sorted based on User's Feedback
Answer / student
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
struct library
{
char title[30];
char author[30];
char edition[30];
char price[30];
char publisher[30];
char category[30];
};
void titlesearch();
void authorsearch();
void categorysearch();
struct library batch[50];
void main()
{
clrscr();
for(int a=0; a<2; a++)
{
puts("Enter title of the book: ");
gets(batch[a].title);
puts("Enter author name: ");
gets(batch[a].author);
puts("Enter edition: ");
gets(batch[a].edition);
puts("Enter price: ");
gets(batch[a].price);
puts("Enter publisher: ");
gets(batch[a].publisher);
puts("Enter category: ");
gets(batch[a].category);
}
titlesearch();
authorsearch();
categorysearch();
for(a=0; a<2; a++)
{
puts(batch[a].title);
puts(batch[a].author);
puts(batch[a].edition);
puts(batch[a].price);
puts(batch[a].publisher);
puts(batch[a].category);
}
getch();
}
void titlesearch()
{ int a;
puts("Enter the title of the book?");
gets(batch[a].title);
}
void authorsearch()
{ int a;
puts("Enter the author of the book?");
gets(batch[a].author);
}
void categorysearch()
{ int a;
puts("Enter the category of the book?");
gets(batch[a].category);
}
| Is This Answer Correct ? | 4 Yes | 3 No |
Answer / sharmaak
Solution is simple. Have a library data structure as a struct containing all the fields
struct library
{
char title[30];
char author[30];
char edition[30];
char price[30];
char publisher[30];
char category[30];
};
But have separate data structure which make different fields searchable in log(n) time.
| Is This Answer Correct ? | 1 Yes | 0 No |
What is structure padding & expalain wid example what is bit wise structure?
write a c program to do the following: a) To find the area of a triangle. b) To convert the temperature from Fahrenheit to Celsius. c) To convert the time in hours : minutes : seconds to seconds.
how to make a scientific calculater ?
Which of the following data structures is on average the fastest for retrieving data: 1) Binary Tree 2) Hash Table 3) Stack
How can I insert or delete a line (or record) in the middle of a file?
the expression a=30*1000+2768; evalutes to a) 32768 b) -32768 c) 113040 d) 0
What kind of structure is a house?
How to explain the final year project as a fresher please answer with sample project
Is it possible to create recycle bin in mobiles?
can we have joblib in a proc ?
What does volatile do?
What is meant by operator precedence?