lecture11-feb13 - Announcements Lecture 11 Assignment 2 due...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Announcements Lecture 11 • Assignment 2 – due today • Assignment 3 out next week – Designs due on Friday at the beginning of your recitation session • Functional block diagram, algorithm, (IPO not required) Functional block diagram shows who calls who (functions), and data passed back and forth An algorithm is a procedure (i.e. a sequence of steps/instructions) for solving a given problem. Flowchart or pseudocode OK. » Tip : level of abstraction should be at least 1:10 • Exam 1 next Friday in class – Study tip: work the sample exam, even # exercises in the book, solutions will be on BB • Topics for today – Basics of functions (Ch. 9) Functions in a Nutshell • A function is a named collection of statements • Somewhat like mathematical functions: y = f ( x ) Arguments are not required {values passed in ( ) } – Does not need to return a value (similar to a procedure in other languages) or returns no value • Functions are like “mini-programs” called by their name – declarations –body • Previously written standard functions are in the library for your use You can write your own functions too, and then call them A Function as a Module values sent in from function calling statement via the arguments supplied in ( ) (optional) Resultant value returned (optional), or function actions that have some other effect Function operation As in, for example: double y = sqrt (x); getchar ( ); printf (“hello\n”); double y = square_it (x); C Standard Library Functions • See appendix D of the book for all the functions available • In various library (header) files (.h) –std l ib –std io –math –t ime –ctype –str ing – assert a few others Top Down Functional Programming main sub1 sub2 sub3 sub4 subsub1 subsub2 subsub3 subsub4 sss1 sss4 calls calls calls calls How does this work? • Partitioning the problem – Let’s us divide a big problem into small problems – No one part is highly complex – However a balance must be achieved between too many and too few functions • Too few may lead to complexity of the size of each • Too many may lead to complexity of the number of interconnects • Many ways to partition a problem – this is one of the fundamentals of the craft of design
Background image of page 1

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

View Full DocumentRight Arrow Icon
Function Mechanics • A function operates on data passed through the parameter list , and either returns a value computed or causes some action to occur • It is called by name from some other function. • The definition of the function consists of a header and a body inside of
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

lecture11-feb13 - Announcements Lecture 11 Assignment 2 due...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online