void draw(float x1, float x2, float y1, float y2) //Numbers are passed in from Main()

{{

system("CLS");

float slope = (y1 - y2) / (x1 - x2); //Finds the slope

cout << "The slope is " << slope;

gotoxy(x1, y2); //This part doesn't work if you use gotoxy(x1, y1)

cout << ".";

gotoxy(x2, y1); //This part doesn't work if you use gotoxy(x2, y2)

cout << ".";

float newx = x1;

float newy = y1;

while(newx != x2) { //This is the most important part of the function

gotoxy(newx, newy); //While the newx (which is x1) is not equal to x2 (the other end of the line segment)

cout << "."; //add the slope to the newx and newy values and draw the new dot

newx = newx + slope;

newy = newy + slope;

}

}}

This function does not work and I am not sure why, if someone could look at it and see if there are any errors I would be very happy. I am not sure what is wrong.

When I enter (1,2), (5,6) for the points it draws them in the correct place, but the line seems to be going the wrong way. It seems when I enter any other points it just keeps on drawing dots for all eternity.