Computer Science, asked by np916872, 5 months ago

. The co-ordinates of two points A and B on a straight line are given as (x1,y1) and (x2,y2). W.A.P.

to calculate the slope(m) of the line by using formula: Slope = (2−1)

(2−1)

Take the co-ordinates (x1,y1) and (x2,y2) as input.​

Answers

Answered by kartikeya327
0

Let the given two points be P(x1, y1) and Q(x2, y2). Now, we find the equation of line formed by these points.

Any line can be represented as,  

ax + by = c  

Let the two points satisfy the given line. So, we have,  

ax1 + by1 = c  

ax2 + by2 = c  

We can set the following values so that all the equations hold true,  

 

a = y2 - y1

b = x1 - x2

c = ax1 + by1

These can be derived by first getting the slope directly and then finding the intercept of the line. OR these can also be derived cleverly by a simple observation as under:

Derivation :  

ax1 + by1 = c ...(i)

ax2 + by2 = c ...(ii)

Equating (i) and (ii),

ax1 + by1 = ax2 + by2

=> a(x1 - x2) = b(y2 - y1)

Thus, for equating LHS and RHS, we can simply have,

a = (y2 - y1)

AND

b = (x1 - x2)

so that we have,

(y2 - y1)(x1 - x2) = (x1 - x2)(y2 - y1)

AND

Putting these values in (i), we get,

c = ax1 + by1  

Thus, we now have the values of a, b and c which means that we have the line in the coordinate plane.

Mark me brainliest

Similar questions