general computer science for engineers cisc 106 lecture 05 james atlas computer and information...

Download General Computer Science for Engineers CISC 106 Lecture 05 James Atlas Computer and Information Sciences 6/22/2009

If you can't read please download the document

Upload: arleen-hampton

Post on 18-Jan-2018

218 views

Category:

Documents


0 download

DESCRIPTION

Review For loop If statement

TRANSCRIPT

General Computer Science for Engineers CISC 106 Lecture 05 James Atlas Computer and Information Sciences 6/22/2009 Lecture Overview Review Plotting Simple Plots Arrays Recursion Review For loop If statement Branching Constructs We already covered the IF statement Why would IF be considered a branch? Branching Constructs Why would IF be considered a branch? Lets look at what happens to our code when it is executing on the CPU Switch construct switch (switch_expression) case case_expr_1 statement 1 statement 2 case case_expr_2 statement 1 statement 2 otherwise statement 1 statement 2 end Switch construct color = yellow; switch (color) case red disp(Stop now!); case green disp(Proceed through intersection.); case yellow disp(Prepare to stop.); otherwise disp(Illegal color encountered.); end For loop for sum integers total = 0; for i = 1:1:100 loop starts at 1 total = total+i; loop increments by 1 end While loop while expression statement end While loop for sum integers total = 0; i = 1; while i