Sunday, March 14, 2010

What happens after you put a semicolon after the test expression in a while loop?

What is it assumed to be?


is it a...?


post-test loop


pre-test loop


infinite loop


null statement


or something that I have not mentioned?

What happens after you put a semicolon after the test expression in a while loop?
Well, it will be a syntax error if you put a semi-colon after using a while statement. You will need to use a do, while loop for you to use the semi-colon after your while statement. Your while statement is considered a pre-test loop and a do-while looop is considered a post-test loop.





Ex: do


{


(statements)


} while (boolean_expression) ; %26lt;---semicolon





while (boolean_expression) %26lt;-- no semicolon


{


(statements)


}



viruses

No comments:

Post a Comment