Program problem

Hi, what is wrong with the program?

I want to take user input (x1,y1) , (x2,y2) and find the radius circonfrence and the area of a circle, and I have to make the program into pieces that's why it has more than int main().






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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
#include <cfloat>
#include <cmath>
#include <cstdlib>

using namespace std;

const double P=3.1416;

int radius(int x1, int x2, int y1, int y2);
int circumfrence(int x1, int x2, int y1, int y2);
int area(int x1, int x2, int y1, int y2);

int main()
{
	int x1,x2,y1,y2;
	
	cout <<"Enter x1 : ";
	cin >> x1;
	cout << endl;
	cout << "Enter y1 : ";
	cin >> y1;
	cout << endl;
	cout << "Enter x2 : " ;
	cin >> x2;
	cout << endl;
	cout << "Enter y2 : " ;
	cin >> y2;
	cout << endl;
	
	cout << radius(x1,y1,x2,y2);


	return 0;
}




int radius(int x1, int x2, int y1, int y2)
{	
	int Distance;
	long double x=(( x2 - x1)^2) +(( y2 -  y1)^2);
	Distance =  sqrt(x);
	cout << Distance << endl;

}

double circumfrence(int Distance)
{	

	cout << 2*P*Distance << endl;



}

double area(int Distance)
{

	cout << P*((Distance)^2)<< endl;

return main();
}
Could you copy and paste the compiler errors and include which line numbers they are on?
Last edited on
There is not error. It's just not giving me what I want :)

If you want to compile it and see the result, here is the code without line numbers:




#include <iostream>
#include <cfloat>
#include <cmath>
#include <cstdlib>

using namespace std;

const double P=3.1416;

int radius(int x1, int x2, int y1, int y2);
int circumfrence(int x1, int x2, int y1, int y2);
int area(int x1, int x2, int y1, int y2);

int main()
{
int x1,x2,y1,y2;

cout <<"Enter x1 : ";
cin >> x1;
cout << endl;
cout << "Enter y1 : ";
cin >> y1;
cout << endl;
cout << "Enter x2 : " ;
cin >> x2;
cout << endl;
cout << "Enter y2 : " ;
cin >> y2;
cout << endl;

cout << radius(x1,y1,x2,y2);


return 0;
}




int radius(int x1, int x2, int y1, int y2)
{
int Distance;
long double x=(( x2 - x1)^2) +(( y2 - y1)^2);
Distance = sqrt(x);
cout << Distance << endl;

}

double circumfrence(int Distance)
{

cout << 2*P*Distance << endl;



}

double area(int Distance)
{

cout << P*((Distance)^2)<< endl;

return main();
}
In C++ ^ is not a power operator. Either use pow or multiplication. For an instance:
1
2
3
4
5
6
double area(int Distance)
{

return P*Distance*Distance;

}


I also don't understand why radius should be integer.
Topic archived. No new replies allowed.