Question: In this exercise, you will make a struct that contains x and y coordinates: struct point {int x; int y;}; The object of this exercise

In this exercise, you will make a struct that contains x and y coordinates: struct point {int x; int y;}; The object of this exercise is to make a singly linked list of these point structures. Add one more member called "next" to your point struct. It is a pointer to the next member of the linked list. The next member of the last point struct should point to NULL, which indicates the end of the list. Your program will read in lines of integers, two integers on each line, representing the x and y coordinates for a point. Your program should keep accepting input until you receive a line of "0 0". For example, for input: You should make three structs, the first with x coordinate 1 and y coordinate 2, the second with x coordinate 0 and y coordinate 1, and the third with x coordinate 1 and y coordinate 3. The first struct's "next" field/member, which is a pointer, will point to the second struct. The second structs "next" field/member will point to the third struct. The third strucfs "next" field/member will point to NULL. After your get your structs stored in memory, you will output the square of the distance of each point to the origin (0, 0), with each result in a new line. For the above input, the expected output should be: Notice that you are NOT allowed to store the structs in an array. They must be in a singly linked list, and the structures must be allocated dynamically. This lab is intended to expose you to the use of pointers, memory allocation, and structures. Pointers and structs are essential in many of the following C.S. classes (e.g. Operating Systems), so please make sure you understand the reading and complete this lab with a thorough understanding
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
