Implementation of DDA Line Algorithm
Here are some flaws in the current algorithm.


xdiff will have a roundoff error if x1-x2 is large in magnitude, likewise for the y variables.
slope is set to 1 for no reason, and then immediately reinitialized to something else.
slope is restricted to an integer, when most slopes will not be integral.
It's impossible to justify setting the slope of a vertical line to 2. There are slopes greater than 2 that are not vertical lines.
In the line slope = (int)xdiff/ydiff;, casting is higher precedence than division, so this will first cast xdiff to an int, overflowing if xdiff &gt; MAXINT, throwing away the fractional part if there is one, then dividing this int by ydiff. The odds of this being the actual slope are very small.
startx and endx are initialized to 0 for no reason, then immediately reinitialized to somethiing else.
Roundoff errors will accumulate as you repeatedly add slope to y (or 1/slope to x).
What's the justification for the abs(y)? If y changes sign in the range, this will cause a kink in the line. Similarly for x.