Basics of Computer Programming

Slides:



Advertisements
Similar presentations
Working With Algorithm and Flowcharts
Advertisements

CS 240 Computer Programming 1
COMPUTER PROGRAMMING I Understand Problem Solving Tools to Design Programming Solutions.
Programming with Alice. Getting Started with Alice Alice is a free programming language – Named in honor of Lewis Carroll – See web page for download.
PSEUDOCODE & FLOW CHART
Chapter 1 - An Introduction to Computers and Problem Solving
ME 142 Engineering Computation I Fundamentals of Procedural Computer Programming.
Chapter 2 - Problem Solving
Basics of Computer Programming Web Design Section 8-1.
8 Algorithms Foundations of Computer Science ã Cengage Learning.
Algorithm Design CS105. Problem Solving Algorithm: set of unambiguous instructions to solve a problem – Breaking down a problem into a set of sub- problems.
Problem Solving Chapter 2. What is an algorithm? n A solution to a problem that is: –Precise –Effective –Terminating.
The Program Design Phases
Original Source : and Problem and Problem Solving.ppt.
CSC103: Introduction to Computer and Programming
Introduction to Programming. What is a Program  Set of Instructions that tells the computer what to Do.  Driving force behind the computer  Without.
1 Introduction to Flowcharting. 2 Writing a program Defining the problem –Write down what the program will do Planning –Write down the steps, draw a flowchart.
Learning to Program with Alice – Chapter 1 September 16, 2009.
CS1501. What is a computer program? A set of instructions to tell the computer what to do It can be elegant! Not only a way to tell a computer what to.
PROGRAM DEVELOPMENT CYCLE. Problem Statement: Problem Statement help diagnose the situation so that your focus is on the problem, helpful tools at this.
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
Algorithms and Pseudocode
Learning Objective To be able to… Understand flow chart symbols Complete and correct flow chart algorithms Create a program based on a flow chart.
ICS124 Session 9 Flowcharting 1. By the end of this section the student will be able to:  Name the three structures of the Structure Theorem  Identify.
CSE 110: Programming Language I Matin Saad Abdullah UB 404.
Program Design & Development EE 201 C7-1 Spring
Algorithms and Flowcharts
PROGRAMMING: What’s It All About?
Component 1.6.
Learning outcomes 5 Developing Code – Using Flowcharts
Understand Problem Solving Tools to Design Programming Solutions
FLOWCHARTS Part 1.
CS1001 Programming Fundamentals 3(3-0) Lecture 2
Understand Problem Solving Tools to Design Programming Solutions
Teaching design techniques to design efficient solutions to problems
Lecture 2 Introduction to Programming
Introduction To Flowcharting
Numbering System TODAY AND TOMORROW 11th Edition
Basics of Computer Programming
Introduction to Algorithm – part 1
2.0 Problem Solving PROGRAM DESIGN
Basics of Computer Programming
Basics of Computer Programming
Print slides for students reference
Unit# 9: Computer Program Development
Problem-Solving and Control Structures By Faith Brenner
Lesson 2 Programming constructs – Algorithms – Scratch – Variables Intro.
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Global Challenge Night Sensor Lesson 2.
Global Challenge Night Sensor Lesson 2.
Design and Implementation
Introduction to Algorithms and Programming
ME 142 Engineering Computation I
Global Challenge Night Sensor Lesson 2.
Global Challenge Night Sensor Lesson 2.
Global Challenge Night Sensor Lesson 2.
My Take on the Largest Number Algorithm
Global Challenge Night Sensor Lesson 2.
Problem-Solving and Control Structures By Faith Brenner
Global Challenge Night Sensor Lesson 2.
Global Challenge Night Sensor Lesson 2.
Flowcharts and Pseudo Code
Global Challenge Night Sensor Lesson 2.
COMPUTATIONAL THINKING COMPUTATIONAL THINKING IN PROGRAMMING
Developing a Program.
Global Challenge Night Sensor Lesson 2.
Global Challenge Night Sensor Lesson 2.
WJEC GCSE Computer Science
Presentation transcript:

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

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

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

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.

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

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.

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

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

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

Flowcharting Example This is a simple flowchart with no connectors Start Read a value Multiply the value by 2 and store in X Display the value entered and X Stop 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?

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) Funnily enough it was a couple of Italian computer scientists that came up with this idea to get over the spagetti problem. They said that all programs can be broken down into the 3 structures shown here. You can either design a program with one structure after the other after the other, or even insert one of the structure inside one of the other structures ( top-down design).

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?

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

Friendship Algorithm

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)

Your Turn… 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.