I am supposed to take the following program fragment and use goto statements to show the flow control through the the loop:
for ( int i = n; i > 0; i-- ) {
if ( x != A[i] )
break;
}
I realize that goto statements should be avoided, but this is what the question is asking for. I think this is what it should be, so that the flow control is shown through the loop:
for ( int i = n; i > 0; i-- ) {
if ( x != A[i] )
goto xValue;
break;
}
xValue: cout << "The value of x: \n" << x;
Is this correct? I am not positive about whether to place the goto statement before or after the break statement.