Given two co-ordinates, find the slope of a straight line.
Input : x1 = 4, y1 = 2, x2 = 2, y2 = 5 Output : Slope is -1.5
Approach: To calculate the slope of a line you need only two points from that line, (x1, y1) and (x2, y2). The equation used to calculate the slope from two points is:
Below is the implementation of the above approach:
Slope is: -1.5
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Find points at a given distance on a line of given slope
- Slope of the line parallel to the line with the given slope
- Slope of perpendicular to line
- Program to find the mid-point of a line
- Program to find line passing through 2 Points
- Find the other end point of a line with given one end and mid
- Find Partition Line such that sum of values on left and right is equal
- Find foot of perpendicular from a point in 2 D plane to a Line
- Find an Integer point on a line segment with given two ends
- Given n line segments, find if any two segments intersect
- Program to find sum of 1 + x/2! + x^2/3! +...+x^n/(n+1)!
- Program to find the sum of a Series (1*1) + (2*2) + (3*3) + (4*4) + (5*5) + ... + (n*n)
- Program to find LCM of 2 numbers without using GCD
- Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +.......+ n/n!
- Program to find GCD or HCF of two numbers
- Program to find LCM of two numbers
- Program to find the sum of the series 1 + x + x^2+ x^3+ .. + x^n
- Program to find sum of series 1 + 1/2 + 1/3 + 1/4 + .. + 1/n
- Program to find the Nth term of series 5, 12, 21, 32, 45......
- Program to find absolute value of a given number
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : vt_m