Chapter 6

3 Pages
Unlock Document

Information Technology Management
ITM 200
Vikraman Baskaran

Chapter 6 – Loops While Loop • Executes a group of statements as long as a condition is true • Before the loop starts, it checks the condition of the while loop is true, if not the loop is not run • Programmer use while loop, with the number times it should loop is unknown • Well suited to writing indefinite loops • A “while” loop may be used if the number of repetitions is not known, as in the case of reading the numbers until the input is 0 The while loop, general syntax: while () { ; } Example: int number = 1; while (number <= 200) { System.out.print(number + " "); number *= 2; Sentinel Value – is an input value to signify to end the loop The do/while Loop - Executes statements repeatedly while a condition is true, testing it at the end of each repetition - Similar to a while loop, except that its body statement(s) will always execute the first time, regardless of whether the condition is true or false - A “do-while” loop can be used to replace a while
More Less

Related notes for ITM 200

Log In


Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.