0

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:usersemcydocumentsvisual studio 2008projectscirclecirclecircle.cpp(38) : error C2064: term does not evaluate to a function taking 4 arguments
1>c:usersemcydocumentsvisual studio 2008projectscirclecirclecircle.cpp(39) : error C2064: term does not evaluate to a function taking 1 arguments
1>c:usersemcydocumentsvisual studio 2008projectscirclecirclecircle.cpp(40) : error C2064: term does not evaluate to a function taking 1 arguments
1>c:usersemcydocumentsvisual studio 2008projectscirclecirclecircle.cpp(41) : error C2064: term does not evaluate to a function taking 1 arguments
1>c:usersemcydocumentsvisual studio 2008projectscirclecirclecircle.cpp(64) : error C2659: '=' : function as left operand
1>c:usersemcydocumentsvisual studio 2008projectscirclecirclecircle.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:usersemcydocumentsvisual studio 2008projectscirclecirclecircle.cpp(71) : error C2659: '=' : function as left operand
1>c:usersemcydocumentsvisual studio 2008projectscirclecirclecircle.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:usersemcydocumentsvisual studio 2008projectscirclecirclecircle.cpp(81) : error C2659: '=' : function as left operand
1>c:usersemcydocumentsvisual studio 2008projectscirclecirclecircle.cpp(81) : error C2143: syntax error : missing ';' before 'return'
1>c:usersemcydocumentsvisual studio 2008projectscirclecirclecircle.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:UsersEmcyDocumentsVisual Studio 2008ProjectscirclecircleDebugBuildLog.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;
}

Edited by Reverend Jim: Fixed formatting

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by NathanOliver
0

I believe this is because your function names and your variable names are the same. try changing all of your function names to start with a capital letter

double Radius(double x, double y, double xs, double ys);
double Diameter(double x);
double Circumference(double x);
double Area(double x);

// instead of

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

Also please use code tags when posting code. It makes it much easier to read.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.