I am brand new to programming and am takinga class in C++. So far I have been able to successfully create the programs requested and get the needed output but this problem has got me stumped. The original problem is to create a program that prompts the user to enter the center and a point on the circle. Then it should output (to screen) the circle's radius, diameter, circumference, and area. I have defined all the parameters and created the functions but I have the following errors in the debugger (btw I am using visual studio2010).
errors:
IntelliSense: no instance of overloaded function "distance" matches the argument list. line 65 column 7
IntelliSense: too few arguments in function call. Line 65, 69, 73, 77 and 81
Because of these errors nothing runs/outputs.
Here is the code that I have:
Any help or direction at this point would be greatly appricated. I have tried several different things to get it to work but to no avail.Code:#include <iostream> #include <cmath> using namespace std; //function to figure out the distance int distance (int x1, int y1, int x2, int y2) { int dx = x2 - x1; int dy = y2 - y1; double dsquared = dx*dx + dy*dy; double result = sqrt (dsquared); return result; } //function to figure out the radius int radius (int x1, int y1, int x2, int y2) { double radius = distance (x1, y1, x2, y2); return radius; } //function to figure out the circumference int circumference(double radius) { double circumference = 3.1416 * (radius * 2); return circumference; } //function to figure out the area int area(double radius) { double area = 3.1416 * radius * radius; return area; } //function to figure out the diameter int diameter(double radius) { double diameter = 2 * radius; return diameter; } int main() { int x1; //variable to store the center point of the circle int x2; //variable to store the second point on the circle int y1; //variable to store the center point of the circle int y2; //variable to store the second point on the circle cout <<"Enter a center point: "; cin >> x1, y1; cout <<"Enter a point on the circle: "; cin >> x2, y2; //distance return cout <<"The distance of the circle is: " << distance() << endl; //area return cout <<"The area of the circle is: " << area() << endl; //radius return cout <<"The radius of the circle is: " << radius() << endl; //circumference return cout <<"The circumference of the circle is: " << circumference() << endl; //diameter cout <<"The diameter of the circle is: " << diameter() << endl; return 0; }
Many thanks.
lostinprogramC+



LinkBack URL
About LinkBacks





you'll find quickly that functions are the easiest thing next to variables. I think they are.