Computer Science, asked by kundusampa621, 7 months ago

The co-ordinates of two points A and B on a straight line are given as (x1,y1) and
(x2,y2). Write a program to calculate the slope (m) of the line by using formula:
(y2 - y1)
Slope
(x2 - x1)
Take the co-ordinates (x1,y1) and (x2,y2) as input.​

Answers

Answered by rupshanandy2
4

Answer:

#include<iostream>

using namespace std;

int main()

{

      int x1,x2,y1,y2;

      cin>>x1>>x2>>y1>>y2;

      int m=(y2-y1)/(x2-x1);

       cout<<"Slope of the line is:"<<m<<endl;

}

Explanation:

formula of slope m= (y2-y1)/(x2-x1)

I wrote the solution in c++

Similar questions