Question

Write this program in C language

Ensure the program output is exactly as described, and that the whitespace of your source code is well formatted. Utilise goo

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Your given problem can be easily solved by implementing singly linked list concept, i have written the code for using the same concept.

The code is written with well inline docs. and screenshots are also attached , kindly follow them for better uderstanding.

----------------------------------------------- code ------------------------------------------

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

// movie Structure

struct Movie

{

    char name[50];

    int release_year;

    int rotten_tomatoes_rating;

    // pointer member to represent sequel

    struct Movie *has_sequel;

};

// print_movie method  

void print_movie(struct Movie *movie){

    // printing detail of the movie

    printf("Name : %s\n",movie->name);

    printf("Year of Release : %d\n", movie->release_year);

    printf("Rotten Tomatoes : %d%%\n", movie->rotten_tomatoes_rating);

    if(movie->has_sequel!=NULL){

        // if it has next sequel

        printf("%s's sequel was....\n\n",movie->name);

        // calling print_movie recurrsively to print all the sequels

        print_movie(movie->has_sequel);

    }else{

        // if it has no sequel

        printf("%s has no sequel, yet!\n", movie->name);

    }

}

// main method

int main()

{

    // creating first movie

    struct Movie *movie;

    movie = (struct Movie *)malloc(sizeof(struct Movie));

    strcpy(movie->name, "Jurassic Park");

    movie->release_year = 1993;

    movie->rotten_tomatoes_rating = 93;

    movie->has_sequel = NULL;  // initially setting has_sequel to NULL as we don't know yet

    // creating second movie

    struct Movie *movie1;

    movie1 = (struct Movie *)malloc(sizeof(struct Movie));

    strcpy(movie1->name, "The Lost World : Jurassic Park");

    movie1->release_year = 1997;

    movie1->rotten_tomatoes_rating = 51;

    movie1->has_sequel = NULL; // initially setting has_sequel to NULL as we don't know yet

    // creating third movie

    struct Movie *movie2;

    movie2 = (struct Movie *)malloc(sizeof(struct Movie));

    strcpy(movie2->name, "Jurassic Park III");

    movie2->release_year = 2001;

    movie2->rotten_tomatoes_rating = 50;

    movie2->has_sequel = NULL; // initially setting has_sequel to NULL as we don't know yet

    // creating fourth movie

    struct Movie *movie3;

    movie3 = (struct Movie *)malloc(sizeof(struct Movie));

    strcpy(movie3->name, "Jurassic World");

    movie3->release_year = 2015;

    movie3->rotten_tomatoes_rating = 72;

    movie3->has_sequel = NULL; // initially setting has_sequel to NULL as we don't know yet

    // creating sequel links

    movie->has_sequel = movie1;

    movie1->has_sequel = movie2;

    movie2->has_sequel = movie3;

    

    // calling print_movie with first movie

    print_movie(movie);

    return 0;

}

-------------------------------------- screenshots ----------------------------------------------------

------------------------------------------------------ output ---------------------------------------------------

iif you like it, please upvote (:

Add a comment
Know the answer?
Add Answer to:
Write this program in C language Ensure the program output is exactly as described, and that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ Language I have a class named movie which allows a movie object to take the...

    C++ Language I have a class named movie which allows a movie object to take the name, movie and rating of a movie that the user inputs. Everything works fine but when the user enters a space in the movie's name, the next function that is called loops infinetly. I can't find the source of the problem. Down below are my .cpp and .h file for the program. #include <iostream> #include "movie.h" using namespace std; movie::movie() { movieName = "Not...

  • WONT COMPILE ERROR STRAY / TEXT.H AND CPP PROGRAM SAYING NOT DECLARED HAVE A DRIVER WILL...

    WONT COMPILE ERROR STRAY / TEXT.H AND CPP PROGRAM SAYING NOT DECLARED HAVE A DRIVER WILL PASTE AT BOTTOM MOVIES.CPP #include "movies.h" #include "Movie.h" Movies *Movies::createMovies(int max) { //dynamically create a new Movies structure Movies *myMovies = new Movies; myMovies->maxMovies = max; myMovies->numMovies = 0; //dynamically create the array that will hold the movies myMovies->moviesArray = new Movie *[max]; return myMovies; } void Movies::resizeMovieArray() { int max = maxMovies * 2; //increase size by 2 //make an array that is...

  • Need this in C++ Goals: Your task is to implement a binary search tree of linked...

    Need this in C++ Goals: Your task is to implement a binary search tree of linked lists of movies. Tree nodes will contain a letter of the alphabet and a linked list. The linked list will be an alphabetically sorted list of movies which start with that letter. MovieTree() ➔ Constructor: Initialize any member variables of the class to default ~MovieTree() ➔ Destructor: Free all memory that was allocated void printMovieInventory() ➔ Print every movie in the data structure in...

  • WRITE IN LANGUAGE C. THANKS Heroic Game Write a program that plays a simple game. Mostly...

    WRITE IN LANGUAGE C. THANKS Heroic Game Write a program that plays a simple game. Mostly the purpose of the program is to practice using structs. Here is a struct that contains information about a character in the game: typedef struct {   int hitPoints;    /* how much life */   int strength;     /* fighting strength */   char name[MAXNAME]; } Hero; The same structure is used for all characters (even non-heroic.) First write the function void printHero( Hero hr )that prints a...

  • Using an object-oriented approach, write a program to read a file containing movie data (Tile, Director,...

    Using an object-oriented approach, write a program to read a file containing movie data (Tile, Director, Genre, Year Released, Running Time) into a vector of structures and perform the following operations: Search for a specific title Search for movies by a specific director Search for movies by a specific genre Search for movies released in a certain time period Search for movies within a range for running time Display the movies on the screen in a nice, easy to read...

  • [C++] Outline: The movie data is read from a file into an array of structs and...

    [C++] Outline: The movie data is read from a file into an array of structs and is sorted using the Selection Sort method and the search is done using the Binary Search algorithm with the year of release as key. This assignment upgrades to an array of pointers to the database elements and converts the Selection Sort and Binary search procedure on the database to selection sort and binary search on the array of pointers to the database.   Requirements: Your...

  • Write MySQL query statements for the questions below including the output that proves the accuracy of...

    Write MySQL query statements for the questions below including the output that proves the accuracy of your solution. Your answers should be stored in a text file that captures your interaction with MySQL. 1. Find the movieID, title, year and DVDPrice of all movies where the DVD-Price is equal to the discountPrice. 2. Find the actorID, lastName, firstName, middleName, and suffix of all actors whose middleName is not NULL. 3. Suppose you remember a movie quote as “Play it again,...

  • Case: Enron: Questionable Accounting Leads to CollapseIntroductionOnce upon a time, there was a gleaming...

    Case: Enron: Questionable Accounting Leads to CollapseIntroductionOnce upon a time, there was a gleaming office tower in Houston, Texas. In front of that gleaming tower was a giant “E,” slowly revolving, flashing in the hot Texas sun. But in 2001, the Enron Corporation, which once ranked among the top Fortune 500 companies, would collapse under a mountain of debt that had been concealed through a complex scheme of off-balance-sheet partnerships. Forced to declare bankruptcy, the energy firm laid off 4,000...

  • CASE 20 Enron: Not Accounting for the Future* INTRODUCTION Once upon a time, there was a...

    CASE 20 Enron: Not Accounting for the Future* INTRODUCTION Once upon a time, there was a gleaming office tower in Houston, Texas. In front of that gleaming tower was a giant "E" slowly revolving, flashing in the hot Texas sun. But in 2001, the Enron Corporation, which once ranked among the top Fortune 500 companies, would collapse under a mountain of debt that had been concealed through a complex scheme of off-balance-sheet partnerships. Forced to declare bankruptcy, the energy firm...

  • 10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated...

    10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated sludge operation that adversely affect effluent quality with origins in the engineering, hydraulic and microbiological components of the process. The real "heart" of the activated sludge system is the development and maintenance of a mixed microbial culture (activated sludge) that treats wastewater and which can be managed. One definition of a wastewater treatment plant operator is a "bug farmer", one who controls the aeration...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT