Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer in c++ Question 11. (10 marks). Pointers and Structures ou are to complete the implementation of code that represents a line in a

image text in transcribed
image text in transcribed
Please answer in c++
Question 11. (10 marks). Pointers and Structures ou are to complete the implementation of code that represents a line in a two-dimensional plane. The skeleton of the code is given to you below. The code uses pointers and structs. Namely, the declarations of the two structures, struct point and struct line, are provided to you. You will need to complete the implementation of the function create line. Here are the requirements create.line takes four parameters, representing the x and y coordinates of the end point 1 and the X and Y coordinates of the end point 2. This function should dynamically allocate memory spacc to represent the line and points. You have to use struct line and struct point to represent the line and point. In create.line, you are not allowed to declare any additional variables other thanp and q. In addition, you cannot use p in the code you write, i.e., you can only use ain . At the end of createline, all of the dynamically allocated memory space has to be deleted. That is, at the end of create line, there should be no memory leak. create-line should output one line: "The 1ine is from (srex, srcy) to (dstx,dsty)." Where srcx, srcy, dstx, dsty are coordinate values of the two points. .You do not need to worry about any error handling. For example, you do not need to check that the input values are valid coordinates. An example invocation of create.line is provided in the main function. This line will cause create line to output: "The 1ine is from (2,3) to (7,8)." struct point f int *x; int *y; 2; struct 1ine f struct point *x; struct point *y; Page 17 of 2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions

Question

What is the 4 bit binary number with a decimal value of 3

Answered: 1 week ago

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago