Instructions

User Manual:

Open the PDF directly: View PDF PDF.
Page Count: 2

5/28/2019 Lab 1
https://ohlone.instructure.com/courses/6963/assignments/139701 1/2
Lab 1
Due Feb 9 by 8am Points 10 Submitting a file upload File Types pdf and tgz
Available until Feb 9 at 8am
This assignment was locked Feb 9 at 8am.
Exercise 1
Define a structure Point. A point has an x- and a y-coordinate. Write
a function
double distance(Point a, Point b)
that computes the distance from a to b. Write a program that reads the
coordinates of the points, calls your function, and displays the result.
Exercise 2
Using the Point structure from the previous exercise, write a function
Point midpoint(Point a, Point b)
that computes the point that is halfway
between a and b. Write a program that reads the coordinates of the points,
calls your function, and displays the result.
Exercise 3
Define a structure Triangle that contains three Point members. Write a
function that computes the perimeter of a Triangle. Write a program that
reads the coordinates of the points, calls your function, and displays
the result.
Exercise 4
Re-implement the Triangle structure (and the perimeter function) of previous
exercise so that it contains two arrays of three double values each,
one for the x-coordinates and one for the y-coordinates.
For each of these exercises, run your program and capture the output into a png file. Then include that
image in block comments of your program using the Latex includegraphics command. Add comments to
each function of your programs explaining what the function does.
Use cpp2pdf to create the PDF that will have all source, code, images and comments nicely formatted and
easy to read. Use the Latex newline command where needed to make logical breaks in the program
structure. Change author to your name, not mine.
5/28/2019 Lab 1
https://ohlone.instructure.com/courses/6963/assignments/139701 2/2
Save your work by using this command in the working directory (lab1), retrieve the tgz and pdf file using the
web server, and upload and submit to Canvas.

Navigation menu