CSE 174 Chapter Notes - Chapter 4: Cash Register, Monte Carlo Method, Random Number Generation

42 views2 pages

Document Summary

Loops repeatedly execute instructions until a goal has been reached. The while loop syntax while (condition) { statements. If the condition remains true, the statements will continue to execute. Used to execute statements a given number of times. Syntax for (int counter = 1; counter <= 10; counter++) { The first part is the initialization- it occurs before the loop starts. The second part is the condition that is checked before each iteration. The last is the update that executes after each loop iteration. Used to execute loop at least once and then check condition. Sentinel- a value that is not actual input but serves as a signal for termination. Boolean values can also be used to control loops- set it before entering the loop and then set it to the opposite to exit the loop. The break statement can be used to exit a loop.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents