Quiz #9

this quiz ask us to make a progam that ask the user about 2 coordinates, and the program has to calculate the distance between those coordinates.

Resultado de imagen para plano cartesiano

Image taken from Definicion https://definicion.mx/plano-cartesiano/

Captura.PNG

#include <cmath>
#include <iostream>
using namespace std;
double distancia (double x1,double x2,double y1,double y2)
{
double d= sqrt(pow(x2-x1,2)+pow(y2-y1,2));
return d;
}
int main ()
{
double x1, x2, y1, y2;
cout << «escribe tu primer cordenada de x y y » << endl;
cin >> x1;
cin >> y1;

cout << «escribe tu segunda coordenada de x y y» << endl;
cin >> x2;
cin >> y2;

double d = distancia(x1, x2, y1, y2);

cout << «la distancia entre las dos coordenadas es » << d << endl;
return 0;
}

Captura.PNG

Deja un comentario