#include <iostream>
#include <cmath>
using namespace std;
double pendiente(double y1, double y2, double x1, double x2)
{
    return (y2 - y1) / (x2 - x1);
}
double distancia (double x2, double x1, double y2, double y1)
{
    return sqrt ((x2 - x1)*(x2 - x1) + (y2 - y1) * (y2 - y1));
}
int main() {

    double y1 =7;
    double y2 = 12;
    double x1 = 3;
    double x2 = 8;
    cout<< "Linea 1, pendiente =";
    cout << pendiente (y1, y2 , x1 , x2 );
    cout << " y distancia =";
    cout << distancia (x2, x1, y2, y1 );
    y1= 10;
    y2 = 6;
    x1 = 2;
    x2 = 12;
    cout << "\nLinea 2, pendiente =";
        cout << pendiente (y1, y2, x1, x2);
        cout << " y distancia=";
    cout << distancia (x2, x1, y2, y1);
    y1= 3;
    y2 = 3;
    x1 = 3;
    x2 = 11;
    cout << "\nLinea 3, pendiente =";
        cout << pendiente (y1, y2, x1, x2);
        cout << " y distancia=";
    cout << distancia (x2, x1, y2, y1);
    y1= 0;
    y2 = 1;
    x1 = 2;
    x2 = 10;
    cout << "\nLinea 4, pendiente =";
        cout << pendiente (y1, y2, x1, x2);
        cout << " y distancia=";
    cout << distancia (x2, x1, y2, y1);
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: