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]
Answer Posted / 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 |
Post New Answer View All Answers
WRITE A CODE IN C TO SEARCH A FILE FROM NOTEPAD FILE.
What is a good data structure to use for storing lines of text?
Write a program to swap two numbers without using third variable?
write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list
How can I avoid the abort, retry, fail messages?
How do we make a global variable accessible across files? Explain the extern keyword?
What is #define?
which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above
What is this pointer in c plus plus?
Explain can static variables be declared in a header file?
main() { printf("hello"); fork(); }
Where define directive used?
How do you define a function?
void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }
Is c procedural or functional?