CS 106A Lecture 5: CS 106A Lecture Notes Week 2 Wed
Document Summary
Interactive programs: reads input from the console. The program pauses, waiting for the user to type a value. The value typed by the user is stored in a variable: readint(), readdouble(), readline(), and readboolean(, requires user input in order to continue program. Revisiting if/else: executes one group if a test is true, another if false, to test the if/else statement, we use relational operators. >= greater than or equal to: to create several possibilities of if statements, use if/ else if/ else statements. You can also end with an else if statement, which makes the program do nothing if none of the statements are true: logical operators. Precedence: arithmetic (addition, multiplication, etc. ) relational (less than equal, etc. ) Revisiting for loops: for (initialization; test; update) { statements, perform initialization once, repeat the following: Revisiting while: repeatedly executes its body as long as a logical test is true, sentinel loops. Sentinel: a value that signals the end of user input.