1. ## problem with function

Hi, everything running smooth but there is 1 mistake cuz my output is always 0.00000

The function should basically return the distance between the points
idk whats wrong tho.

Code:
```#include <stdio.h>
#include <math.h>

//Distance funktion

double distance(double x1, double y1, double x2, double y2, double erg1){
return sqrt(pow(x2,-x1)+pow(y2,-y1));
}

int main()

{
double x1,y1,x2,y2,erg1;

printf("x1 y1 x2 y2");
scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
printf("The distance is %lf", distance);
return 0;

}``` 2. Isn't distance a function?

A decent compiler would at least warn you about the problem, if it is setup correctly. 3. ## y Originally Posted by jimblumberg Isn't distance a function?

A decent compiler would at least warn you about the problem, if it is setup correctly.

we have to use gcc, and i'm supposed to write the function myself ^^
no warnings, but the result is just 0.000 4. You need to enable warnings for GCC, e.g. add the -Wall and -Wextra flags.

Code:
`warning: format '%lf' expects argument of type 'double', but argument 2 has type 'double (*)(double,  double,  double,  double,  double)` 5. You should probably also look up what pow does, because once you do get an answer you're still not going to like the answer you get.

And what is the purpose of erg1? 6. Hi Lyrockzz!

Adrian is right, you need 4 arguments used by 'distance' in line 22.

erg1 is unused and can receive the return value of 'distance'
example:
Code:
```#include <stdio.h>
#include <math.h>

//Distance funktion
double distance(double x1, double y1, double x2, double y2){
return sqrt(pow((x2-x1), 2) + pow((y2-y1), 2));
}

int main()
{
double x1,y1,x2,y2, erg1;

printf("x1 y1 x2 y2: ");
scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
erg1 = distance(x1, y1, x2, y2);

printf("The distance is %lf", erg1);
return 0;
}```
example for input and output on the screen:
x1 y1 x2 y2: 0 0 50 86.6025403
The distance is: 100.000000 7. Originally Posted by -Adrian You need to enable warnings for GCC, e.g. add the -Wall and -Wextra flags.

Code:
`warning: format '%lf' expects argument of type 'double', but argument 2 has type 'double (*)(double,  double,  double,  double,  double)`
but my type is "double" i dont get the error ^^ 8. I was referring to the code you originally posted, where distance is a function (function-pointer), not a double. Anyway, looks like you've been shown a solution. 9. Thanks, Now i get it, sorry im still figuring out how to properly use functions and everything, helped alot  Popular pages Recent additions %lf, beginner programmer, double, return, studying 