For example, in Java used in a loop? Why is this a bad practice or bad form? Example:
what would be the best way to do this? Like this?Code:int count; // control variable also used after loop terminates for ( count = 1; count <= 10; count++ ) // loop 10 times { if ( count == 5 ) // if count is 5, break; // terminate loop System.out.printf( "%d ", count ); } // end for System.out.printf( "\nBroke out of loop at count = %d\n", count );
Code:int count; // control variable also used after loop terminates for (count = 1; count <= 4; count++) // loop 5 times { System.out.printf("%d ", count); } // end for System.out.printf("\nBroke out of loop at count = %d\n", count);


Reply With Quote