CS99, Fall 2002 Lecture 3, Mon 9/9 ------------------------------------------------------------------------------- Announcements: + h1 due tomorrow in lab + h2 posted later on Tues or Weds this week (due date will account for YK) + remember to read on-line announcements, newsgroup, and notes ------------------------------------------------------------------------------- Summary from Lecture 2 + Problems->Solution Process->Solution + Process: brainstorm, research, outline, draft, polish, test + Outline: algorithm (sequence of instructions written in pseudocode) + Stepwise refinement + iteration and testing (haven't gotten to these yet!) ------------------------------------------------------------------------------- How to go from algorithm to code? Use Computer Language: + need to translate English language algorithm into a computer language + many options: MATLAB, Maple, Java, C, C++, C#, etc + Choose MATLAB and Java for CS100 + see $help lang$ for summary + from Help browser: MATLAB->Using MATLAB->Programming and Data Types ------------------------------------------------------------------------------- Language Elements + computer language usually written (in the future, spoken) + has syntax (grammar) and semantics (meaning) + keyboard characters (alphabet) -> tokens (words) -> statements (sentences) ------------------------------------------------------------------------------- Characters + usually keyboard characters (ASCII text) + ASCII has 128 characters + some are nonprinting -- see ascii.txt for full list + also, try entering $char(32:127)$ in MATLAB (do not enter $s: I use the $ notation to indicate a code fragment or statement to enter) ------------------------------------------------------------------------------- Tokens + characters form "words", which are called TOKENS + tokens include: numbers, operators, variables, keywords, punctuation, token separators, strings, comments (described in more detail soon) + technically, MATLAB uses arrays for *everything* - arrays are collections of items - think "spreadsheet" for now... ------------------------------------------------------------------------------- Statements + combine tokens to create "sentences", which are called STATEMENTS + each "sentence" forms an instruction/command + "sentences" are called statements -------------------------------------------------------------------------------