Hey all...
I have a homework assignment and I am stumped.
Here is the assignment:
The following formula gives the distance between 2 points x1,x2 and y1,y2 in the cartesian plane:
sqrt(pow(x1-x2,2) - pow(y1-y2,2))
given the center and a point on the circle, you can use this formula to find the radius of the circle. Write a program that prompts user to enter the center a point on the circle. The program should then output the circle radius, diameter, circumference and area. your program must have at least the following function:
a)distance:this function takes as its parameters four numbers that represent tow points in the plane and returns the distance between them.
b)radius:this function takes as its parameters four numbers that represent the center and a point on the circle, calls the function distance to find the radius of the circle, and return the circle radius.
c)circumference: this function takes as its parameter a number that represents the radius of the circle and returns the circle circumference.
d)area: this function takes as its parameter a number that represents the radius of the circle and return the circle area
assume the pi = 3.1416
Here is my code. I get an error!!
1>circle.obj : error LNK2019: unresolved external symbol "double __cdecl area(double)" (?area@@YANN@Z) referenced in function _main
1>circle.obj : error LNK2019: unresolved external symbol "double __cdecl circumference(double)" (?circumference@@YANN@Z) referenced in function _main
1>circle.obj : error LNK2019: unresolved external symbol "double __cdecl radius(int,int,int,int)" (?radius@@YANHHHH@Z) referenced in function _main
1>circle.obj : error LNK2019: unresolved external symbol "double __cdecl distance(int,int,int,int)" (?distance@@YANHHHH@Z) referenced in function _main
1>C:\Users\Tracy\Documents\Visual Studio 2010\p359num8\Debug\p359num8.exe : fatal error LNK1120: 4 unresolved externals
Someone point me in the right direction... please
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#include<iostream>
#include<cmath>
using namespace std;
double distance (int p, int q, int r, int s);
double radius (int p, int q, int r, int s);
double circumference (double r1);
double area (double r1);
int main ()
{
int x1, x2, y1, y2;
double r, d, c, a, p, s, q;
cout<<"Enter the center of the circle: "<<endl;
cin>>x1>>y1;
cout<<"Enter an outer point on the circle: "<<endl;
cin>>x2>>y2;
d= distance (x1, y1, x2, y2);
r= radius (x1, y1, x2, y2);
c= circumference (r);
a= area (r);
cout<< "Distance between points: "<<d<<endl;
cout<< "Radius of circle: "<<r<<endl;
cout<< "Circumference of the circle: "<<c<<endl;
cout<< "Area of circle: "<<a<<endl;
double distance (int p, int q, int r, int s);
double d1;
d1 = sqrt(pow(r-p,2) + pow (s-q, 2));
return d1;
double radius (int p, int q, int r, int s);
double r1;
r1= distance (p,q,r,s);
return r1;
double circumference (double r1);
double c1;
c1= 2*3.1416*r1;
return r1;
double area (double r1);
double a1;
a1= 3.1416*r1*r1;
return a1;
system ("pause");
}
|