CS 111 - 9/15/15 WiCS - Women in Computer Science General Meeting CS Lounge (SEL 2254a) Wed 9/16 at 3pm Free Food!!!! Parameters as Aliases On the first day of class, the professor handed out the syllabus. For CS 111, the professor is Pat Troy For ENGR 100, the professor is Chris Kuypers For MATH 180, the professor is John Steinberger Functions are really a general "statement". The specific information comes when the method/function gets called. Sequential Coding Elements - varaible declarations - assignment statements - method/function calls Iteritive Coding Elements (looping) - while loop Syntax: while ( ) { ; } The will evaluate to either true or false (a boolean value). 5 > 3 ==> true 5 < -13 ==> false In a while loop, the will be executed repeatedly "while the is true". When the becomes false, the while stops executing. int x; x = 1; // initialization while ( x <= 10 ) // condition { System.out.println (x); // body statements x = x + 1; // increment } When writing a while loop, we need/want to include 4 parts 1. initialization 2. condition 3. body statements 4. increment // example of an infinite loop int x; x = 1; // initialization while ( x <= 10 ) // condition { System.out.println (x); // body statements x = x - 1; // increment } Conditions most often use the relational operators less than < less than or equal <= greater than > greater than or equal >= equality (equals) == inequality (not equals) != When using multiple operators in a single statement, be aware of the order of operator precedence The increment and decrement operators: ++ -- special forms to allow an increase or decrease of a variable by 1. the following all do the same thing. (The last two involve the least amount of typing) x = x + 1; x++; ++x; In the while loop: int x; x = 1; // initialization while ( x <= 10 ) // condition { System.out.println (x); // body statements x++; // increment } Beware of a common error when using increment operator: int x; x = 1; // initialization while ( x <= 10 ) // condition { System.out.println (x); // body statements x = x++; // ERROR with increment: x doesn't change }