singularity2006

02-24-2004, 07:42 PM

I have main that calls getVars and passes the values back to main. Them those values are passed to GetSqrt. However, if GetSqrt detects negative values, it calls GetVars itself. However, it is not correctly re-assigning the variable value for getSqrt to use. GetSqrt for some reason still has the first set of values passed from main in memory. What happened?

int getSqrt(int a, int b, int c, float*sqrt_a, float*sqrt_b, float*sqrt_c)

{

/*comparison test to determine if negative numbers were inputted.

if test passes, square roots of variables are taken and returned.

else, the user is notified of the calculation error.*/

do

{

if(a >= 0 && b >= 0 && c >=0)

{

*sqrt_a=(float)sqrt(a);

*sqrt_b=(float)sqrt(b);

*sqrt_c=(float)sqrt(c);

break;

}

else

{

printf("\nSorry, this program cannot evaluate square roots for 'i.'");

printf("\nPlease provide new inputs.\n");

getVars(&a, &b, &c);

}

}while(a < 0 || b < 0 || c < 0);

return 0;

}

int getSqrt(int a, int b, int c, float*sqrt_a, float*sqrt_b, float*sqrt_c)

{

/*comparison test to determine if negative numbers were inputted.

if test passes, square roots of variables are taken and returned.

else, the user is notified of the calculation error.*/

do

{

if(a >= 0 && b >= 0 && c >=0)

{

*sqrt_a=(float)sqrt(a);

*sqrt_b=(float)sqrt(b);

*sqrt_c=(float)sqrt(c);

break;

}

else

{

printf("\nSorry, this program cannot evaluate square roots for 'i.'");

printf("\nPlease provide new inputs.\n");

getVars(&a, &b, &c);

}

}while(a < 0 || b < 0 || c < 0);

return 0;

}