I'm writing a basic piece of code to perform a successive approximation algorithm, however, when it runs the approximation loop, it seems unable to distinguish between a positive and a negative number in that it runs both if statements. The code is shown below, and if someone could point out where im going wrong, it would be really helpful.

``````#include <iostream.h>

int main(void)
{
float num1, num2, num3, num4, num5, num6, est, calcest, calcnum, calcdif, adj;

est = 5.0;

cout << "Please input first number: ";
cin >> num1;
cout <<num1;

cout << "\nPlease input second number: ";
cin >> num2;

cout << "\nPlease input third number: ";
cin >> num3;

cout << "\nPlease input fourth number: ";
cin >> num4;

cout << "\nPlease input fifth number: " ;
cin >> num5;

cout << "\nPlease input sixth number: ";
cin >> num6;

calcest = est * est * est * est * est * est;
cout << "\n" <<calcest;

calcnum = (num1 * num2 * num3 * num4 * num5 * num6);
cout << "\n" << calcnum;

calcdif = calcnum - calcest;
cout << "\n" << calcdif;

while ((calcdif >(-100)) || (calcdif >100));
{
if (calcdif < (-100));
{
}

else if (calcdif > 100);
{
}

calcest = est * est * est * est * est * est;
calcdif = calcnum - calcest;
}
cout << "\nThe geometric mean is" << est;
return 0;
}``````

<< moderator edit: added [code][/code] tags >>

Thanks
Kevin

As posted, I couldn't compile it. You seem to have misplaced several semicolons.

``````while ((calcdif >(-100)) || (calcdif >100));
{
if (calcdif < (-100));
{
}

else if (calcdif > 100);
{