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 |
write a c programs to do multiplication of two numbers with out using arithmatic operator ??????????
Explain can static variables be declared in a header file?
what is the difference between i++ and ++i?
Why n++ execute faster than n+1 ?
Write a program to enter the name and age. If age>28 then find salary categories. if age<28 then find that you are gaduate or not.
#define f(x) main() { printf("\n%d",f(2+2)); }
What are the different categories of functions in c?
Write a code to remove duplicates in a string.
Take an MxN matrice from user and then sum upper diagonal in a variable and lower diagonal in a separate variables. Print the result
void main() { char c; while(c=getchar()!='\n') printf("%d",c); } o/p=11 why?
1 1 1 1 2 1 1 3 3 1 1 4 6 4 1
simple c program for 12345 convert 54321 with out using string