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
|
#include <cstdlib>
#include <iostream>
#include <cmath>
using namespace std;
void calcrac (float, float, float, float, float&, float&, float&);
void getvalues (float&, float&, float&);
int main (int argc, char *argv [])
{float x1, y1, x2, y2, radius, area, circ;
getvalues (x1, y1, x2, y2, radius);
cout<<"Please enter the first x coordinate: ";
cin>>x1;
cout<<"Please enter the first y coordinate: ";
cin>>y1;
cout<<"Please enter the second x coordinate: ";
cin>>x2;
cout<<"Please enter the second y coordinate: ";
cin>>y2;
calcrac (x1, y1, x2, y2, radius, area, circ);
cout<<"Radius = "<<radius<<endl;
cout<<"Area = "<<area<<endl;
cout<<"Circumference = "<<circ<<endl;
system ("PAUSE");
return EXIT_SUCCESS;
}
void calcrac (float x1, float y1, float x2, float y2, float& r,
float& a, float& c)
{ r = sqrt ((pow((x2-x1),2)) + (pow((y2-y1),2)));
a = 3.14 * (pow(r,2));
c= 2*3.14*r;
}
|