#include <iostream>
#include <string>
using namespace std;

double distance(double x[],double y[]){
     return sqrt((y[0]-x[0])*(y[0]-x[0])+(y[1]-x[1])*(y[1]-x[1]));
int main(){
    double d;
    double x[]={1,2};
    double y[]={4,3};
   return 0;}

why wont it work
I also tried


but it wont work either

The pbroblem is that you are passing the arrays to the function wrong. If you want to pass the arrays it will look like this

cout << distance(x, y) << endl;

Since your function is set up to take an array you just pass the entier array by using the name. what you are doinW is passing the value one past the end of the array

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.