The equation for the slope of a line between two points is

(y2 - y1)/(x2 - x1)

You can use any values for x1, x2, y1, and y2 in your program.