471,873 Members | 2,025 Online

M:\lineX\lineX.cpp(38) : error C2447: missing function header (old-style formal list?

1
//----------------------------------------------------------------
//This program will find the length of a line on a plane. With the
//one end at the origin and the other end selected by the user and
//print it to screen.

# include <math.h>
# include <stdlib.h>
# include <iomanip.h>
# include <iostream.h>

int main()
{

//Define constants, variables, and prototypes.
double length(double x, double y);
double x_in,y_in;

//Have user enter values for x and y.
cout << " Enter in the values for x and y. " <<endl;
cout << " Enter x value." <<endl;
cin >> x_in;
cout << " Enter y value." <<endl;
cin >> y_in;

//Print anwser to screen.
cout << "The length of the line is equal to " << length <<"."<<endl;

//Exit program.
return 0;

}

//-----------------------------------------------------------------
//This function evaluates the length of the line.
//
double length(double x, double y);
*{

sqrt(pow(x_in,2)+pow(y-in,2));
return length;
}

//-----------------------------------------------------------------

The astric is where the program has the error. What is wrong?
Sep 27 '06 #1
1 3708
D_C
293 100+
Expand|Select|Wrap|Line Numbers
1. double length(double x, double y);
2. *{
should be
Expand|Select|Wrap|Line Numbers
1. double length(double x, double y)
2. {
Also
Expand|Select|Wrap|Line Numbers
1.   cout << "The length of the line is equal to " << length <<"."<<endl;
should be
Expand|Select|Wrap|Line Numbers
1.   cout << "The length of the line is equal to " << length(x_in,y_in) <<"."<<endl;
Sep 27 '06 #2