finding side and angle of triangle in a circle

hi i want to write a C++ program that will:

a) compute the positive values y for x = (a-r) to x=(a+r).
y = b+(sqrt( (r*r) - ((x - a)*(x - a)) ))

b) compute the negative values y for x=(a-r) to x=(a+r).
y = b-(sqrt( (r*r) - ((x - a)*(x - a)) ))

c) compute the maximum value of y.

d) compute the minimum value of y.

e) compute the (y-b)/r for each y value computed in part a) and b) above.
(to find angle A-> this is found by sine rule., (y-b) is the opposite side of angle A and r is the hypoteneuse).
The program should make use of at least two programmer-defined functions.

so far i have done this:
/*-Program name- main.cpp
-Program statement- The equation of a circle given as (r*r) = ((x - a)*(x - a)) + ((y - b)*(y - b)). with centre at coordinate points x=a, y=b and radius r. we have to solve y given y = b+/-( ( r2 -(x - a)2 )).
-Inputs- float a, b, r, x, y.
-Outputs- y = b+/-( ( r2 -(x - a)2 )), min and max value of y, angle A
*/

#include <iostream>
#include <cmath>
using namespace std;

//function prototype
float calcCoord_y1 (float a, float b, float r, float x);
float calcCoord_y2 (float a, float b, float r, float x);
float findMaxValueOf_y (float y1, float y2);
float findMinValueOf_y (float y1, float y2);
float find_angle1 (float y1, float b, float r);
float find_angle2 (float y2, float b, float r);

//start of main function
int main()
{
float a = 1;
float b = 1;
float y1;
float y2;
float x = 1;
float r = 5;
float max_y;
float min_y;
float angle1;
float angle2;

//using for loop for value of x
for ( x = -1; x <=5; x = x + 1)
{
//Function call statement

y1 = calcCoord_y1 (a, b, r, x);
y2 = calcCoord_y2 (a, b, r, x);

cout << "\n\nx = " << x ;
cout << "\ny1 = " << y1;
cout << "\ny2 = " << y2 << endl;
max_y = findMaxValueOf_y (y1, y2);
min_y = findMinValueOf_y (y1, y2);
angle1 = find_angle1 (y1, b, r);
angle2 = find_angle2 (y2, b, r);

}
system ("pause");
return 0;
}

//---------------------------------------------------

float calcCoord_y1 (float a, float b, float r, float x)
{
float y1 = 0;

y1 = b+(sqrt( (r*r) - ((x - a)*(x - a)) ));
return y1;
}

float calcCoord_y2 (float a, float b, float r, float x)
{
float y2 = 0;

y2 = b-(sqrt( (r*r) - ((x - a)*(x - a)) ));

return y2;
}

float findMaxValueOf_y (float y1, float y2)
{
float highest = y1;

if (highest < y2)
{
highest = y2;
} cout << "max value of y = " << highest << endl;
return highest;
}

float findMinValueOf_y (float y1, float y2)
{
float lowest = y1;

if (lowest > y2)
{
lowest = y2;
} cout << "min value of y = " << lowest << endl;
return lowest;
}

float find_angle1 (float y1, float b, float r)
{
float angle;
angle = asin((y1-b)/r);

cout << "angle = " << angle << endl;
return angle;
}

float find_angle2 (float y2, float b, float r)
{
float angle;
angle = asin((y2-b)/r);

cout << "angle = " << angle << endl;
return angle;
}

after i compile the program it displays an invalid value of the angle. can you tell me what i have done wrong? and why i am getting an invalid answer? everything else is alright, i think.
hi, can you describe as well what your program has to do?
Topic archived. No new replies allowed.