Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

TASK: A small library management program in C language the program should only u

ID: 3712259 • Letter: T

Question

TASK: A small library management program in C language

the program should only use arrays pointers functions switches. i am a beginner and i am not good with some advance coding so i will prefer the program to be simple. the user will have following as output

OUTPUT:
1: ENTER BOOKS
2:EDIT DATA
3: SEARCH BOOKS
4: DELETE DATA
5:ISSUE BOOKS
6: RETURN BOOKS
7:EXIT

IN ENTER BOOK section the user will enter book name with author and price which can be edited further in SEARCH section...

NOTE : I PREFER PROGRAM TO BE SIMPLE AND EASY TO UNDERSTAND

Explanation / Answer

I have implmented a small c code to implement the libarary management system.The two functions enter_books() and search_books() enables a user to enter a new book into the library and search through the avilable books respectively.

The book data has been stored in a structure of a library which initially allows 20 books to be entered.However,it can be expanded very easily.It is only a small program so I have fixed the value to 20.The other functions are not specified and thus no definition is available for them.But the structure stores the data of a book by its name,author_name and price.The search() function then takes up a search term and checks through the entire structure if that book exists,if it does,then it asks the user to enter a new name and edits the previous name.

The code is being put here:

#include<stdio.h>

#include<string.h>

#include<PROCESS.h>

int j=0;

struct library

{

int num[20];

float price[20];

char name[20][40],author_name[20][40];

}lib;

void enter_books()

{

printf(" Enter book name:");

gets(lib.name[j]);

printf(" Enter author name:");

gets(lib.author_name[j]);

printf(" Enter book price:");

scanf("%f",&lib.price[j]);

j++;

}

void edit_data();

void search_books()

{

char b_name[40],r_name[40];

printf(" Enter book name:");

gets(b_name);

for(j=0;j<20;j++)

{

if(strcmp(b_name,lib.name[j])==0)

{

printf(" Enter new book name");

gets(r_name);

strcpy(lib.name[j],r_name);

}

}

}

void delete_data();

void issue_books();

void return_books();

void main()

{

int choice;

do

{

printf(" 1...ENTER BOOKS");

printf(" 2...EDIT DATA");

printf(" 3...SEARCH BOOKS");

printf(" 4...DELETE DATA");

printf(" 5...ISSUE BOOKS");

printf(" 6...RETURN BOOKS");

printf(" 7..EXIT ");

scanf("%d",&choice);

switch(choice)

{

case 1:enter_books();break;

case 2:edit_data();break;

case 3:search_books();break;

case 4:delete_data();break;

case 5:issue_books();break;

case 6:return_books();break;

case 7:exit(0);break;

default:printf(" Invalid choice!");

}

}

while(choice!=7);

}

Note: lib is an instance of the library structure.