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



Define a structure to store the record of library. The record must consist of at least following f..

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

Define a structure to store the record of library. The record must consist of at least following f..

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

Post New Answer

More C Interview Questions

What is macro?

5 Answers   IBM,


main() { static char *s[]={"black","white","yellow","voilet"}; char **ptr[]={s+3,s+2,s+1,s}, ***p; p=ptr; **++p; printf("%s",*--*++p+3); }

1 Answers  


What does sizeof function do?

0 Answers  


How can you pass an array to a function by value?

0 Answers  


What is array within structure?

0 Answers  






Explain the meaning of keyword 'extern' in a function declaration.

0 Answers  


A woman had somany gloves and hats 22 red,34 blue, 45 white...there was power cut and she took a glove and how many gloves shud she take so that she gets a pair of glove fr each color??

3 Answers   TCS,


write a c program thal will find all sequences of length N that produce the sum is Zero, print all possible solutions?

0 Answers   Wipro,


1)what is the error in the following stmt where str is a char array and the stmt is supposed to traverse through the whole character string str? for(i=0;str[i];i++) a)There is no error. b)There shud be no ; after the stmt. c)The cond shud be str[i]!='\0' d)The cond shud be str[i]!=NULL e)i shud be initialized to 1

4 Answers  


what are bit fields? What is the use of bit fields in a structure declaration?

0 Answers   Flextronics, TISL, Virtusa,


Can you define which header file to include at compile time?

0 Answers   Aspire, Infogain,


second highest number in a given set of numbers

3 Answers   TCS,


Categories