Equation of a Line



Finding the equation of a Line Given Two End Points



Write a program for finding the equation of a Line Given Two End Points (x1,y1) and (x2, y2)
The equation for a line is Y = MX + C
Where M = Slope of a Line and C = Intercept
To Find the slope of a line
slope = (y2 - y1) / (x2 - x1)
To Find the intercept of the line, intercept = y1 - (slope) * x1
which would be same as, intercept = y2 - (slope) * x2

Input/Output:

Program to find the equation of a line given two end points
Enter X1: 2
Enter Y1: 3
Enter X2: 5
Enter Y2: 7
Equation of the line with end points (2, 3 and (5, 7) : Y = 1.33333X +0.333333

2 comments:

  1. You can also get some good c programs at www.vitedu.in with download option.

    ReplyDelete
  2. Nice...i like this
    check out this blog for more programs http://orientar4u.blogspot.in/p/engineering-seminars.html

    ReplyDelete