Lecture 3 Notes

13014 the answer is in between l and w wsl 41 13014

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ruct The else clause does not have a condition (boolean expression) 1/30/14 n༆  n༆  n༆  n༆  n༆  33 1/30/14 34 Important Features of Iteration Itera=on n༆  n༆  The idea of Repe==on The for- loop construct 1/30/14 At most one branch of statements is executed There can be any number of elseif clauses There can be at most one else clause The else clause must be the last clause in the construct The else clause does not have a condition (boolean expression) n༆  n༆  35 A task can be accomplished if some steps are repeated; these steps form the loop body Need a starting point Need to know when to stop Need to keep track of (and measure) progress— update 1/30/14 36 1/31/14 Pattern for doing something n times Syntax of the for loop for <var>= <star t value>:<incr>:<end bound> n= for k= 1:n statements to be executed repeatedly % code to do % that something end Loop body Loop header specifies all the values that the index variable will take on, one for each pass of the loop. E.g, k= 3:1:7 means k will take on the values 3, 4, 5, 6, 7, one at a time...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online