You are given the slope of one line (m1) and you have to find the slope of another line which is perpendicular to the given line.
Input : 5 Output : Slope of perpendicular line is : -0.20 Input : 4 Output : Slope of perpendicular line is : -0.25
Suppose we are given two perpendicular line segments AB and CD. The slope of AB is m1 and line CD is m2 .
m1 * m2 = -1
From above, we can say
m2 = – 1/( m1 ) .
How does above formula work?
Let slope of line AB be m1 and we need to find slope of line CD. Below diagram gives an idea about working of formula.
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.