1 / 5

The Five Steps

The Five Steps. Understanding the problem Do a small example by hand Write an algorithm for solving the problem Translate the algorithm into a programming language (like C) Test the program. Ways to solve problems. Top down approach Break problem up into smaller problems

florine
Télécharger la présentation

The Five Steps

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Five Steps • Understanding the problem • Do a small example by hand • Write an algorithm for solving the problem • Translate the algorithm into a programming language (like C) • Test the program

  2. Ways to solve problems • Top down approach • Break problem up into smaller problems • Bottom up approach • Solve smaller problem and then add features • Examples: payroll problem (book), stock market portfolio (started last lecture) • Combined approach

  3. Where are we now? • Understand what a function is and main() • Understand declaration of variables • Able to write simple programs that can write to output (printf) • Able to write simple programs that perform mathematical operations (know about expressions) • Able to write simple programs that can read from inputs (scanf) • Able to comment programs • Know a systematic way of testing and debugging a program

  4. Stock Portfolio Task Write a program to analyze a stock portfolio consisting of some number of different stocks we own. For each stock we have information on how many shares we own, how much we paid for each share, and how much each share is worth now. Stock prices are expressed as a whole dollar amount and a fraction (e.g. 1/2, 1/4, 1/8, etc.). We would like to compute how our portfolio is worth and how much profit we have made if we liquidated it today.

  5. Why use functions? • Modularity: helpful for top down design and organization of programs • Repeating tasks: many engineering problems require that certain task be repeated • Testing and debugging programs

More Related