CS 161 Lecture Notes - Lecture 4: Switch Statement
25 views2 pages
8 Feb 2018
School
Department
Course
Professor
Document Summary
Cs 161 lecture 4 more conditionals (short lecture: guest speakers and group work) If/else/if else: put some condition and if it is true it will act out. If it is false it will go to the else or if else statement: different categories in same questions, the computer will keep going down the options until one of them is true. Relational and logical operators: used to test variables, == equality, >= greater than or equal to, <= less than or equal to, > greater than, < less than. I i or: and: if((1/2) && (2/5), or: if((1>2) i i (2>5), not: if(! (1>2) && (2<5), non-zero numbers are true and zero is false. Short circuiting: compiler wants to be lazy, for and statements, if the first one is false, does not check the second one, problems can occur because maybe the whole statement is true.