Strictly speaking, it should be floating-point coordinates, but integers make the problem extremely simple. Floating-point values are approximate, and, these days, unfortunately, not so many people understand how to correctly work with them. Now, remember your Algebra 1, geometry, or whatever you learned, and think: what would make the problem of of drawing a line between two points indeterminate? Right, if two points have the same location, then you can draw infinite number of straight lines, from one point. So, you got one condition. There is another case: "infinite" derivative. This is when two x-coordinates are the same. In this case, if y-coordinates are different, you can draw a single straight line through two points, but this line would be vertical.
I would not worry that this line is vertical, because, the slope can be infinite (even though this case is not really covered by school algebra or even "elementary" calculus, but such thing can be formalized; the floating-point type even have special Inf values which you could assign to the result). The problem is that, with just two points, this infinite slope can be interpreted as either +Inf or −Inf, that is, this is an infinite case again. Note that this is the same very case where the integer division in your formula would give an exception. So, you can do another check for this case, or, too look cool :-), catch this exception and output your "underfined" when it is caught.
As this looks like a home assignment, no code samples for you. If you did not find out how to analyze this simplest mathematical problem, at least write the code with your own hands. I explained you 100% of what you need. And if you don't do such things with your own hands, you don't really learn; this simple idea has been proven on many examples.
Good luck,
—SA