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

We are writing the new website to replace amazon.com. We are storing information

ID: 3574839 • Letter: W

Question

We are writing the new website to replace amazon.com. We are storing information about books, specifically the meta-data about titles, authors, and chapter information. In the code below, I have defined a struct (named "Chapter") that holds information regarding the page counts for the chapters of a book. This struct is always located with an array of Chapters inside of another struct (named "Book"). You need to write a function (named "longest_chapter") that takes a book and prints the title of the longest chapter within (and how many pages long that chapter was). # include struct Chapter {char title(100); int first_page;}; struct Book {char title (100); char author (100); int total_pages; struct Chapter chapters(100); int number_of_chapters;}; void longest_chapter(struct Book b); int main (void) {struct Book b; scanf ("%99(" ) "/b. title); scanf("%99('' ) "/b.author); scanf("Total Pages %d", &b.total; pages); scanf("%d Chapters ", &b;, number_of_chapters); for (int chapter_number = 0; chapter_number

Explanation / Answer

Hi, Please find my implementation of required function.

Please let me know in case of any issue.

void longest_chapter(struct Book b){

   char lon_chap_index = 0;

   int i;

   for(i=1; i<b.number_of_chapters; i++){

       if(b.chapters[i].first_page > b.chapters[lon_chap_index].first_page){
           lon_chap_index = i;
       }
   }

   printf("Longest chapater title : %s ", b.chapters[lon_chap_index].title);
   printf("Number of pages: %s ", b.chapters[lon_chap_index].first_page);
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote