Linked List – Arithmetic – Problem #6
IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive
Problem Statement
Define a structure “node” to store a link list of integers. Write a function void make_list(node *l, int n) to read n integers and store them in a link list. Write a function node *reverse_list(node *l) which takes as input a link list and returns another list that stores the elements in opposite order of the original list. Write a main program to – Read an integer n. Then uses make_list to read n integers and stores them in a list l. Call reverse_list to reverse the list l. Print elements of the new list. Example: Input: 1, 2, 3, 4, 5 Output: 5, 4, 3, 2, 1