C programing

  1. Create a structure as shown below to represent a point in the Cartesian plane:

    typedef struct {

    double x;

    double y; }Point;

  2. Create a second structure that models a line segment, which consists of two points, using the structure definition as shown:

    typedef struct {

    Point start;

    Point end; }Line_segment;

  3. Write a void function that has one parameter of type Point and displays that point to the console in the form (x, y).
  4. Write a void function that has one parameter of type Line_segment and displays that line segment to the console in the form P1, P2 (where P1 and P2 will be displayed using the function in step 3 above).
  5. Write a void function that has one parameter of type Point, and displays the position of that point on the Cartesian plane (origin, x-axis, y-axis, Quadrant I, Quadrant II, Quadrant III, or Quadrant IV).
  6. Add the function calculate_length to your program. This function should take one parameter of type Line_segment and return its length.

Steps 7-9 should be done in main:

  1. Declare two Point variables, p1 and p2. Prompt the user to enter coordinates for each. Display each point using the function from step 3.
  2. Create a Line_segment variable and use the user-entered points as start and end. Display the line using the function from step 4.
  3. Call the function from step 4 and output the result with 3 decimal places.
  4. Test your program thoroughly.