Everything I touch in programming gets ruined. Errors all over the place.
It's another group project, but this time we have to present it to the class and it refuses to compile. We don't even understand the errors. The program is supposed to return the distance between two input coordinates.
Here's what we have so far:
Code:
#include <iostream>
#include <stdlib.h>
#include <math.h>

using namespace std;
int GetCoordinate ();
double GetDistance (double X1, double Y1, double X2, double Y2);
void PrintResults (/*double d, double X1, double Y1, double X2, double Y2*/);

int main(int argc, char *argv[])
{
  double X1=0;
  double Y1=0;
  double X2=0;
  double Y2=0;
  double d;
  GetCoordinate();
  d = GetDistance (double X1, double Y1, double X2, double Y2);
  PrintResults();
system ("PAUSE");
  return 0;
}  

int GetCoordinate ();
    {
        cout << "Enter the coordinates of two points (X1,X2),(Y1,Y2)" << endl;
        cin >>X1>>X2>>Y1>>Y2;
    }
    
    double GetDistance /*(double X1, double Y1, double X2, double Y2, double d)*/;
    {
        double d = sqrt(pow((Y2-Y1), 2.0) + pow((X2-X1), 2.0));
    }
    
    void PrintResults (double d, int X1, int Y1, int X2, int Y2);
    {
        cout << "The distance between ("<<X1<<", "<<X2<<") and" << endl;
        cout<< "("<<Y1<<", "<<Y2<<") is "<<d<<"." << endl;
    }
Here is our collection of errors that we cannot sort out.
  • N:\distancecode.cpp In function `int main(int, char**)':
  • 18 N:\distancecode.cpp syntax error before `,' token
  • distancecode.cpp N:\distancecode.cpp At global scope:
  • 25 N:\distancecode.cpp syntax error before `{' token
  • 27 N:\distancecode.cpp syntax error before `>>' token
  • 30 N:\distancecode.cpp `double GetDistance' redeclared as different kind of symbol
  • 7 N:\distancecode.cpp previous declaration of `double GetDistance(double, double, double, double)'
  • 31 N:\distancecode.cpp syntax error before `{' token
  • 36 N:\distancecode.cpp syntax error before `{' token
  • 38 N:\distancecode.cpp syntax error before `<<' token
  • [Linker error] undefined reference to `GetDistance(double, double, double, double)'

Maybe these are really easy to fix but we're too inexperienced to figure out what to do. If someone would please shed some light on these errors we'd be much obliged.