lecture05_controls_2

# Lecture05_controls_2 - EE312 Lecture 5 Announcements Assignment 2 Posted Tuesday don't wait to start Due next Thursday Book has lots of good

This preview shows pages 1–6. Sign up to view the full content.

1 1 EE312 - Lecture 5 Announcements • Assignment 2 – Posted Tuesday - don’t wait to start – Due next Thursday • Book has lots of good exercises at the end of each chapter for those who might be struggling - Take your book along to Friday recitation sessions as TAs will be covering many of these exercises. • Read Chapter 8 - Arrays • Topics for today will address: – More on looping (Ch. 6) – Finish non numeric data types (Ch. 7) 2 Reviewing Problem Solving and Algorithms Programs are made of Algorithms (implemented as functions in C) and Data Structures (implemented as variables, arrays, etc.)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2 3 What is an Algorithm? An algorithm is a procedure (i.e. a sequence of steps/instructions) for solving a given problem. It must be correct, complete, unambiguous, terminating, “executable”(by the execution agent) and understandable. • A given problem may be solvable by a number of different algorithms. Its importance is crucial in figuring out a solution procedure. • An algorithm may be transformed into a working program if its computable • An algorithm will typically use levels of abstraction to make the solution clearer and implementation easier. • An algorithm may be represented in several ways: Pseudocode - structured English language used to help design an algorithm (free form; e.g. recipe) Flowchart - a graphical representation of an algorithm. It shows control and data flow. Formal languages - outside the scope of this course 4 How To Shampoo Your Hair 1) Wet your hair 2) Apply shampoo 3) Lather 4) Rinse 5) Repeat Follow these simple steps: Found on the back of a shampoo bottle - circa 1965
3 5 How To Shampoo Your Hair 1) Wet your hair 2) Apply shampoo 3) Lather 4) Rinse 5) Repeat Follow these simple steps: Steps 1 - 4 depict a sequential ﬂow of instructions Step 5 introduces the notion of repetition/iteration of instructions 6 How To Shampoo Your Hair 1) Wet your hair 2) Apply shampoo 3) Lather 4) Rinse 5) Repeat Follow these simple steps: 0) If out of shampoo, then run out and buy some This is a decision making statement

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
4 7 How To Shampoo Your Hair 1) Wet your hair 2) Apply shampoo 3) Lather 4) Rinse 5) Repeat steps 1 - 4, if necessary Follow these simple steps: This is a bounded iteration statement 8 How To Shampoo Your Hair 1) Wet your hair 2) Set the wash hair counter to 0 3) Repeat steps 3A - 3D while the value of wash hair counter is less than 3 (i.e. do it three times) A. Apply shampoo B. Lather C. Rinse D. Add 1 to the wash hair counter 4) Stop Follow these simple steps: This is what pseudocode looks like
5 9 Program control logic • More complex problems require the ability of a program to contain situational decision logic that provides for alternative paths of execution: 1. Instructions done in sequence (what we have seen so far) can be grouped 2. Selection among alternative paths of execution 3. Iteration/repetition of a set of instructions • C has several types of statements for implementing these capabilities • But first we need to understand these at the

This preview has intentionally blurred sections. Sign up to view the full version.

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

## This note was uploaded on 04/07/2008 for the course EE 312 taught by Professor Shafer during the Spring '08 term at University of Texas at Austin.

### Page1 / 22

Lecture05_controls_2 - EE312 Lecture 5 Announcements Assignment 2 Posted Tuesday don't wait to start Due next Thursday Book has lots of good

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online