Presentation is loading. Please wait.

Presentation is loading. Please wait.

Basics of Computer Programming Web Design Section 8-1.

Similar presentations

Presentation on theme: "Basics of Computer Programming Web Design Section 8-1."— 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: Terminal Input/ Output Processing Call Decision

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

11 Flowcharting Example 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

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

13 Flowcharting 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?

14 Flowcharting 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


16 Friendship Algorithm

17 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: 1. Sequential processing (a list of instructions) 2. Conditional Processing (Ifs) 3. Looping or Iteration (repeating) 4. Problem decomposition (Breaking Things Into Smaller Pieces) 5. Calling a function (Compute a Result)

18 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.

Download ppt "Basics of Computer Programming Web Design Section 8-1."

Similar presentations

Ads by Google