loops...?

i am trying to program a neural network using back propigation.
but when i enter the weights, and if they are not between 1 and -1 then an error message appears. how do i loop it back to the the start to re-enter the weights when using the "if" statement.

e.g.

cout << endl << "weight A: ";
cin >> WA;
cout << endl << "weight B: ";
cin >> WB;


if ( -1 < WA > 1 )
if ( -1 < WB > 1 )

cout << endl << " ERROR! Number out width range, please re-enter: ";

cheers stuart.


Last edited on
Use a while loop.

1
2
3
4
5
6
7
8
9
10
11
12
13
while ((-1 < WA > 1) && (-1 < WB > 1) )
{
cout << endl << "weight A: ";
cin >> WA;
cout << endl << "weight B: ";
cin >> WB;


if ( -1 < WA > 1 )
if ( -1 < WB > 1 )

cout << endl << " ERROR! Number out width range, please re-enter: ";
}
Last edited on
Topic archived. No new replies allowed.