I have a few errors that I can't figure out

Well I'm having quite a bit of errors with my code and have tried figuring out how to fix it, but I can't seem to figure out what is wrong. Here are the errors



1>------ Build started: Project: circle, Configuration: Debug Win32 ------
1>Compiling...
1>circle.cpp
1>c:\users\emcy\documents\visual studio 2008\projects\circle\circle\circle.cpp(38) : error C2064: term does not evaluate to a function taking 4 arguments
1>c:\users\emcy\documents\visual studio 2008\projects\circle\circle\circle.cpp(39) : error C2064: term does not evaluate to a function taking 1 arguments
1>c:\users\emcy\documents\visual studio 2008\projects\circle\circle\circle.cpp(40) : error C2064: term does not evaluate to a function taking 1 arguments
1>c:\users\emcy\documents\visual studio 2008\projects\circle\circle\circle.cpp(41) : error C2064: term does not evaluate to a function taking 1 arguments
1>c:\users\emcy\documents\visual studio 2008\projects\circle\circle\circle.cpp(64) : error C2659: '=' : function as left operand
1>c:\users\emcy\documents\visual studio 2008\projects\circle\circle\circle.cpp(66) : error C2440: 'return' : cannot convert from 'double (__cdecl *)(double)' to 'double'
1> There is no context in which this conversion is possible
1>c:\users\emcy\documents\visual studio 2008\projects\circle\circle\circle.cpp(71) : error C2659: '=' : function as left operand
1>c:\users\emcy\documents\visual studio 2008\projects\circle\circle\circle.cpp(73) : error C2440: 'return' : cannot convert from 'double (__cdecl *)(double)' to 'double'
1> There is no context in which this conversion is possible
1>c:\users\emcy\documents\visual studio 2008\projects\circle\circle\circle.cpp(81) : error C2659: '=' : function as left operand
1>c:\users\emcy\documents\visual studio 2008\projects\circle\circle\circle.cpp(81) : error C2143: syntax error : missing ';' before 'return'
1>c:\users\emcy\documents\visual studio 2008\projects\circle\circle\circle.cpp(81) : error C2440: 'return' : cannot convert from 'double (__cdecl *)(double)' to 'double'
1> There is no context in which this conversion is possible
1>Build log was saved at "file://c:\Users\Emcy\Documents\Visual Studio 2008\Projects\circle\circle\Debug\BuildLog.htm"
1>circle - 11 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========




And here is the code:





#include <iostream>
#include <cmath>

using namespace std;

double radius(double x, double y, double xs, double ys);
double diameter(double x);
double circumference(double x);
double area(double x);

const double pi = 3.141;

int main()

{
double centerX;
double centerY;
double pointX;
double pointY;
double radius;
double diameter;
double circumference;
double area;

cout << "This program will calculate the radius, diameter, circumference and area \n of a circle if the user gives the locaction of the center point and \n a point on the circle."<< endl;
system("pause");
system("cls");

cout << "Enter the x coordinate for the center of the circle. \n" << endl;
cin >> centerX;
cout << "Enter the y coordinate for the center of the circle. \n" << endl;
cin >> centerY;
cout << "Now enter the x coordinate for any point on the circle. \n" << endl;
cin >> pointX;
cout << "Now enter the y coordinate for any point on the circle. \n" << endl;
cin >> pointY;

radius = radius(centerX, centerY, pointX, pointY);
diameter = diameter(radius);
circumference = circumference(radius);
area = area(radius);

cout << "The radius of the circle is " << radius << endl;
cout << "The diameter of the circle is " << diameter << endl;
cout << "The circumference of the circle is " << circumference << endl;
cout << "The area of the circle is " << area << endl;

return 0;

}


double radius(double x, double y, double xs, double ys)
{
double radius;
radius = sqrt(pow((x-xs),2) + pow((y-ys),2));

return radius;
}


double diameter(double x)
{
diameter = x * 2;

return diameter;
}

double circumference(double x)
{
circumference = 2 * pi * x;

return circumference;
}

double area(double x)

{
area = pi * pow(x,2)

return area;
}
I am not sure what you are doing here
double radius;
double diameter;
double circumference;
double area;

but
1>c:\users\emcy\documents\visual studio 2008\projects\circle\circle\circle.cpp(38) : error C2064: term does not evaluate to a function taking 4 arguments

thinks that double radius is your FUNCTION and not a variable

I'd change the name of the functions to calcRadius, calcCirumference ....so there is no confusion with what are variables and what are functions
hi
i guess you can not use radius and diameter and circumference and area as function in main routine because you declare in as variables too.just change the name of the variable .
Topic archived. No new replies allowed.