Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question

C program only 

 

Down below is a menu-driven program about library operations. Help me because I don't know how to put an update and delete transactions. Also, please edit the program so it can have file manipulation/handling.

Required input:

 

 

CODE:

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct book
{
     int  b_no;
     char b_name[40];
     char b_author[40];
     int  no_pg;
};


int main()
{
     struct book b[20];
     int    ch,n,i,count = 0;
     char   temp[40];
     do
     {
           printf("\n**************************************\n");
           printf("\nMENU DRIVEN LIBRARY OPERATIONS PROGRAM\n");
           printf("\n**************************************\n");
          printf("\n\nCHOOSE FROM THE GIVEN OPTIONS BELOW:\n");
          printf("\n--------------------------------------------\n");
          printf("\nPRESS 1 - TO ADD BOOK DETAILS");
          printf("\nPRESS 2 - TO DISPLAY BOOK DETAILS");
          printf("\nPRESS 3 - TO SEARCH A BOOK/S OF A GIVEN AUTHOR");
          printf("\nPRESS 4 - TO EXIT\n");
          printf("\n--------------------------------------------\n");
          printf("Enter Your Choice: ");
          scanf("%d",&ch);
          switch(ch)
          {
               case 1:
                    printf("\nHow many records you want to add? : ");
                    scanf("%d",&n);
                    printf("-------------------------------------\n");
                    printf("ADD BOOK/S DETAILS\n",n);
                    printf("-------------------------------------\n");
                    for(i = 0 ; i < n ; i++)
                    {
                         printf("Enter Book Number : ");
                         scanf("%d",&b[i].b_no);
                         printf("Book Name : ");
                         scanf("%s",b[i].b_name);
                         printf("Enter Author Name : ");
                         scanf("%s",b[i].b_author);
                         printf("Enter Number of Pages : ");
                         scanf("%d",&b[i].no_pg);
                         printf("-------------------------------------\n");
                    }
                    break;
               case 2:
                    printf("\n\t\tDETAILS OF THE BOOK/S");
                    printf("\n-----------------------------------------------------------\n");
                    printf("Book No.   Book Name\t  Author Name\tNo. of Pages");
                    printf("\n------------------------------------------------------------");
                    for( i = 0 ; i < n ; i++)
                    {
                         printf("\n %d\t  %s\t  %s\t  %d",b[i].b_no,b[i].b_name,b[i].b_author,b[i].no_pg);
                    }
                    printf("\n\n");
                    break;
             case 3:
                     printf("-------------------------------------\n");
                    printf("SEARCH A BOOK/S OF GIVEN AUTHOR\n",n);
                    printf("-------------------------------------\n");
                    printf("\nEnter Author Name: ");
                    scanf("%s",temp);
                    printf("--------------------------------------");
                    for( i = 0 ; i < n ; i++)
                    {
                         if(strcmp(b[i].b_author,temp) == 0)
                         {
                              printf("\n%s\n",b[i].b_name);
                         }
                    }
                    break;
               case 4 :
                    exit(0);
          }
     }while(ch != 4);
     return 0;
}

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Engineering
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY