1 / 18

Basics of Computer Programming

Basics of Computer Programming. Web Design Section 8-1. Computer Programs. A computer program is nothing more than a set of instructions that tells the computer what to do A computer program is also a way to tell another human being what you want the computer to do

nate
Download Presentation

Basics of Computer Programming

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. Basics of Computer Programming Web Design Section 8-1

  2. Computer Programs • A computer program is nothing more than a set of instructions that tells the computer what to do • A computer program is also a way to tell another human being what you want the computer to do • Part of writing a computer program is to include documentation • Comments in the code, written document, etc. • Helps another human being understand what you are trying to do

  3. Building Blocks of a Program • All computer programs are made from simple ideas… • A List of Instructions • Example: • Beat eggs • Mix in flour, sugar and shortening • Pour into a pan • Bake at 375 degrees for 45 minutes • This is called sequential processing

  4. Building Blocks of a Program • Ifs • If something is true do this, otherwise do that… • Example – If it is raining take an umbrella • This is called Conditional Processing • Repeating Behavior • Examples: • Stomp your foot five times • While there are cookies on the plate, keep eating cookies • This is called Looping or Iteration

  5. Building Blocks of a Program • Breaking Things Into Smaller Pieces • Example: • To clean the house we will first clean the kitchen, then clean the bathroom, and then clean the bedrooms one at a time. • This is called problem decomposition, stepwise refinement or top-down design • It’s really just breaking a complicated task down into a list of simpler tasks and then doing all those simple tasks.

  6. Building Blocks of a Program • Compute a Result • Performing a sequence of tasks to obtain a result that is the answer to a question • Examples: • Look in the phone book and find the number for Rebecca Smith (Question really is “What is Rebecca Smith’s phone number?) • Put this baby on the scale and tell me how many pounds she weighs. (How much does the baby weigh?) • The question is known as a function and asking the question to get a result is known as calling a function

  7. Computer Programming • Computer programming is just using those ideas in various combinations. • Computers really only understand about 100 different instructions! • The millions of programs that are out there are simply different combinations of those 100 instructions.

  8. Designing a Program • The best way to design a program or for someone else or to see the logical flow of your own program is by sketching the design on paper. • One way of doing this is a visual representation called a Flowchart

  9. Flowcharts • Flowcharts are constructed using a set of basic symbols: Processing Terminal Input/ Output Call Decision

  10. Flowcharting • Along with the symbols certain connectors are needed: On Page Connector Off Page Connector

  11. This is a simple flowchart with no connectors To follow the logic of a flow chart you start at the top and read downward. What does this program do? Start Read a value Multiply the value by 2 and store in X Display the value entered and X Stop Flowcharting Example

  12. Simple Selection (IF-THEN-ELSE) Simple Repitition (Loop) Simple Sequence The Three Programming Control Structures. • All programs can be described by combining these 3 control structures:

  13. This is a simple flowchart for taking a bath. Each of these processes can then be broken down into the steps associated with that process Note the Start and End! What is this program missing? Flowcharting

  14. This is the flowchart for the process “Fill the bathtub with water” This process has decisions and loops! Note that lines coming out of a decision are labeled with the answer Flowcharting

  15. Friendship Algorithm

  16. Summary • A computer program is simply a set of instructions which the computer must follow to solve a problem. • Computer programs are based on 5 simple ideas: • Sequential processing (a list of instructions) • Conditional Processing (Ifs) • Looping or Iteration (repeating) • Problem decomposition (Breaking Things Into Smaller Pieces) • Calling a function (Compute a Result)

  17. Rest of Today • Download 8-1 from the Hancock Web Site • On the first page on the homework the arrows are in the correct places. Simply move the boxes and the text to complete the flowcharts. • For the second page you can use Word or draw the flowchart by hand. • When done print out the homework and turn it in.

More Related