This program that I've made works fine to find midpoint, but not distance. The distancefunction always returns a 1 (true). To try to see that it wasn't the math, I added cout.setf(cout.boolalpha) to see and got a result of "true". I'm very confused and am wondering if anyone with a little more seasoning could help me... Thanks
//This program is a start to solve basic coordinatre plane distances and midpoints
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
You are not calling the function there... you are merely printing a pointer to it.
Calling functions involves giving them (parenthesis).
So:
distancefunction(0);
Would be actually calling your distance function (with the 'distance' parameter being 0).
Though your distancefunction should not have a distance parameter... because the distance is the output, not the input. distancefunction should take no parameters*... then you call it like this
1 2 3 4 5
distancefunction();
// or in a cout statement:
cout << distancefunction() << endl; // <- note the parenthesis
* it actually should take x1,x2,y1,y2 parameters and those should not be globals... but whatever... I'm trying to keep this simple.
As pointed out multiple times in your previous posts about this same problem, you do not actually call the sqrt function. Even though you had this in your very first post.
For example if your 2 points were (0.0,0.0) and (4.0,3.0), your function returns 25.0, not 5.0
Given you repeatedly ask the same question (in a slightly different form) and seem to refuse to use code tags, I am beginning to wonder whether you are trolling.
Thank you so much @Disch . I added in the parenthesis and the 0 and the program works like a charm. Thank you very much!
Dear @TheIdeasMan, I know that I did not put the sqrt of distance in. i don't need or want it for what I'm doing. All I need is the number before the squareroot. the larger program I am working on simplifies squareroots. Thank you for your input. I will be adding code tags to larger programs but this I didn't find it necessary. Later posts i do will feature code tags. Thank you.
Thank for the input everyone (or output in your case! )