By some googling I learnt that through default means we cannot pass the value of array by call by value method.Thus what you have did might be call by reference.
for (int n = 0; n < 50; ++n)
{
cout <<
"Enter a pair of positive x, then y coordinates"" separated by spaces or ‘0 0’ to stop:" << endl;
cin >> CoorX[n] >> CoorY[n];
if (CoorX[n] == 0 && CoorY[n] == 0) // we'll talk about this
break;
// use the values
}
The problem with this is you can't check for zero this way with a floating point number. Floating point variables have a resolution called it's epsilon. You have to check if the value is within the epsilon for zero. http://en.cppreference.com/w/cpp/types/numeric_limits/epsilon
Fot doubles, the code can look like this:
1 2 3 4 5 6 7 8 9
bool isZero(float val)
{
return -FLT_EPSILON < val && val < FLT_EPSILON;
}
bool isZero(double val)
{
return -DBL_EPSILON < val && val < DBL_EPSILON;
}
So the loop becomes:
1 2 3 4 5 6 7 8 9 10 11 12
for (int n = 0; n < 50; ++n)
{
cout <<
"Enter a pair of positive x, then y coordinates"" separated by spaces or ‘0 0’ to stop:" << endl;
cin >> CoorX[n] >> CoorY[n];
if (isZero(CoorX[n]) && isZero(CoorY[n]))
break;
// use the values
}
but I need to pass the two PolVal and PolAngle arrays by reference.
According to the OP:
jumpman530 wrote:
here's the instructions:
1) Make a method which takes as input parameters a pair of rectangular coordinates and sets as output parameters a pair of polar coordinates relative to the same point as the input rectangular coordinates.
You shouldn't be passing arrays to your function at all.
kbw wrote:
The problem with this is you can't check for zero this way with a floating point number.
Yes, you can. 0 is guaranteed to be exactly representable by any floating point type, and since we are going directly from input where the user is asked to input 0, there isn't much point in involving the epsilon value except to make things a little more complex. If one isn't working, the other won't work either. Something else is going on.