Computer science assignment help

computer science


#include <stdio.h>
#include <stdlib.h> /* has the malloc prototype */
#include <string.h> /* has the strcpy prototype */
#define TSIZE 45 /* size of array to hold title */
struct film {
char title[TSIZE];
int rating;
struct film * next; /* points to next struct in list */
void reverse(struct film* head)//recursive function which prints from back
// Base case
if(head == NULL)
// it wil prints from back...recursively
// printing node
printf("Movie: %s Rating: %d\n",
head->title, head->rating);
int main(void)
struct film * head = NULL;
struct film * prev, * current;
char input[TSIZE];
/* Gather and store information */
puts("Enter first movie title:");
while (gets(input) != NULL && input[0] != '\0')
current = (struct film *) malloc(sizeof(struct film));
if (head == NULL) /* first structure */
head = current;
else /* subsequent structures */
prev->next = current;
current->next = NULL;
strcpy(current->title, input);
puts("Enter your rating <0-10>:");
scanf("%d", &current->rating);
while(getchar() != '\n')
puts("Enter next movie title (empty line to stop):");
prev = current;

Instruction Files
2.1 KB

Related Questions in computer science category

The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.