Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.

Slides:



Advertisements
Similar presentations
CS 111: Introduction to Programming Midterm Exam NAME _________________ UIN __________________ 10/30/08 1.Who is our hero? 2.Why is this person our hero?
Advertisements

CHAPTER 1: AN OVERVIEW OF COMPUTERS AND LOGIC. Objectives 2  Understand computer components and operations  Describe the steps involved in the programming.
Chapter 1 - An Introduction to Computers and Problem Solving
Introduction to Programming
Chapter 2 - Problem Solving
Chapter 2 - Problem Solving
زبانهای برنامه سازی برنامه سازی پیشرفته ارائه دهنده دکتر سيد امين حسيني E.mail: Home page:
Starting Out with C++, 3 rd Edition 1 Chapter 1. Introduction to Computers and Programming.
COSC 120 Computer Programming
CIS105 Chapter 1 Theory Review. Page 2 Hardware and Software are the two major components o any computer system Hardware is the set of physical devices.
Chapter 2: Input, Processing, and Output
An Overview of Computers and Logic
An Overview of Programming Logic and Design
Understanding the Mainline Logical Flow Through a Program (continued)
COBOL for the 21 st Century Stern, Stern, Ley Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.
Chapter 1 Program Design
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
Chapter 3 Planning Your Solution
Programming Logic and Design Fourth Edition, Introductory
The Program Design Phases
An Overview of Computers and Programming
PRE-PROGRAMMING PHASE
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Programming Logic and Design Fifth Edition, Comprehensive
An Overview of Computers and Logic
Structured COBOL Programming, Stern & Stern, 9th edition
The abacus has roots dating back over 5,000 years
Programming Logic and Design Sixth Edition Chapter 2 Working with Data, Creating Modules, and Designing High-Quality Programs.
Simple Program Design Third Edition A Step-by-Step Approach
CIS Computer Programming Logic
สาขาวิชาเทคโนโลยี สารสนเทศ คณะเทคโนโลยีสารสนเทศ และการสื่อสาร.
Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step.
PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
Input, Output, and Processing
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
P ROGRAMMING L OGIC AND D ESIGN S IXTH E DITION Chapter 1 An Overview of Computers and Programming.
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
An Object-Oriented Approach to Programming Logic and Design Chapter 1 An Overview of Computers and Logic.
An Introduction to Programming with C++ Sixth Edition Chapter 7 The Repetition Structure.
Flowcharts. Problem Solving Computer programs are written to solve problems or perform tasks Programmers translate the solutions or tasks into a language.
Visual Basic Programming
ALGORITHM List of instructions for carrying out some process step by step. A sequence of instructions which has a clear meaning and can performed with.
What is Programming? A program is a list of instructions that is executed by a computer to accomplish a particular task. Creating those instructions is.
CHAPTER 1 INTRODUCTION 1 st Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
CHAPTER 1 INTRODUCTION 1 st semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
PROGRAM DEVELOPMENT CYCLE. Problem Statement: Problem Statement help diagnose the situation so that your focus is on the problem, helpful tools at this.
CHAPTER 1 INTRODUCTION 2 nd Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
Programming Logic and Design Seventh Edition
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '081 Chapter 2 - Problem Solving 2.1 Program Development Cycle 2.2 Programming Tools.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
Topics Designing a Program Input, Processing, and Output
Chapter 2: Input, Processing, and Output
DDC 1023 – Programming Technique
The Selection Structure
Lecture 2 Introduction to Programming
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Unit# 9: Computer Program Development
Chapter 2- Visual Basic Schneider
Chapter 2: Input, Processing, and Output
Programming Logic and Design Eighth Edition
Presentation transcript:

Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax errors to be run, or executed, on a computer To function properly, the logic must be correct What’s wrong with this logic for making a cake?

Programming Logic and Design, Introductory, Fourth Edition2 Understanding Computer Components and Operations (continued) Logic errors, or semantic errors, are more difficult to locate than syntax errors Logic for multiplying a number by 2 (includes input, processing and output statements)

Programming Logic and Design, Introductory, Fourth Edition3 Understanding the Programming Process Seven programming phases: 1.Define the Problem 2.Outline the Solution 3.Develop the Outline into an Algorithm 4.Test the Algorithm for Correctness 5.Code the Algorithm in a specific language 6.Run the program on the computer 7.Document and maintain the program

Programming Logic and Design, Introductory, Fourth Edition4 Understanding the Programming Process (continued) Define the Problem: –May be the most difficult phase –Users may not be able to articulate their needs well –User needs may be changing frequently –Programmers may have to learn the user’s functional job tasks –Failure to understand the problem is the major cause of most project failures If this is not correct – the rest of the project cannot be correct

Programming Logic and Design, Introductory, Fourth Edition5 Understanding the Programming Process (continued) Outline the Solution: –Plan the high-order steps that the program will take –Walk through the logic before coding by desk- checking the logic

Programming Logic and Design, Introductory, Fourth Edition6 Understanding the Programming Process (continued) Develop the Outline into an Algorithm: –Use tools such as flowcharts and pseudocode –Flowchart: a pictorial representation of the logic steps –Pseudocode: English-like representation of the logic

Programming Logic and Design, Introductory, Fourth Edition7 Understanding the Programming Process (continued) Test the Algorithm for Correctness: –Walk through the logic before coding by desk- checking the logic –Make corrections to the Flowchart/Pseudocode as needed

Programming Logic and Design, Introductory, Fourth Edition8 Understanding the Programming Process (continued) Code the algorithm in a specific language: –Select the programming language –Write the instructions Using software to translate the program into machine language: –Programmers write instructions in English-like high-level languages –Compilers or interpreters change the programs into low- level machine language that can be executed –Syntax errors are identified by the compiler or interpreter

Programming Logic and Design, Introductory, Fourth Edition9 Understanding the Programming Process (continued) Run the program on the computer: –Test for Syntax errors –Test for logic errors by using selected data Using software to translate the program into machine language: –Programmers write instructions in English-like high-level languages –Compilers or interpreters change the programs into low- level machine language that can be executed –Syntax errors are identified by the compiler or interpreter

Programming Logic and Design, Introductory, Fourth Edition10 Understanding the Programming Process (continued) Document and maintain the program: –Create user documentation –Create technical documentation –Create documentation library –Monitor processing and outputs

Programming Logic and Design, Introductory, Fourth Edition11 Understanding the Programming Process (continued) Syntax Error Cycle

Programming Logic and Design, Introductory, Fourth Edition12 Understanding the Programming Process (continued) Testing the program: –Execute it with sample data and check results –Identify logic errors and correct them –Choose test data carefully to exercise all branches of the logic Putting the program into production –Do this after testing is complete and all known errors have been corrected –May require coordination with other related activities or software

Programming Logic and Design, Introductory, Fourth Edition13 Understanding the Data Hierarchy Data hierarchy: ordering of data types by size –Character: single symbol (letter, number, special symbol) “A”, “7”, “$” –Field: group of characters forming a single data item “Smith” –Record: a group of related fields Customer record containing name and address fields –File: a group of related records Customer file, containing all customer records –Database: collection of related files, called tables, that serve the information needs of the organization

Programming Logic and Design, Introductory, Fourth Edition14 Using Flowchart Symbols and Pseudocode Statements Flowchart: pictorial representation of the logic Pseudocode: English-like representation of the logic –Example:

Programming Logic and Design, Introductory, Fourth Edition15 Using Flowchart Symbols and Pseudocode Statements (continued) Flowchart input symbol:

Programming Logic and Design, Introductory, Fourth Edition16 Using Flowchart Symbols and Pseudocode Statements (continued) Flowchart processing symbol

Programming Logic and Design, Introductory, Fourth Edition17 Using Flowchart Symbols and Pseudocode Statements (continued) Flowchart output symbol:

Programming Logic and Design, Introductory, Fourth Edition18 Using Flowchart Symbols and Pseudocode Statements (continued) Flowlines: –Connect the steps –Show the sequence of statements –Have arrows to show the direction Terminal symbol (start/stop symbol): –Shows the start and end points of the statements –Lozenge shape

Programming Logic and Design, Introductory, Fourth Edition19 Using Flowchart Symbols and Pseudocode Statements (continued)

Programming Logic and Design, Introductory, Fourth Edition20 Using Flowchart Symbols and Pseudocode Statements (continued) Back-pointing arrows show statements that will be repeated

Programming Logic and Design, Introductory, Fourth Edition21 Using and Naming Variables Variable: a memory location whose contents can vary; also called an identifier Each programming language has it own rules for naming identifiers, including: –Legal characters –Maximum length –Use of upper or lower case Variable name must be a single word, but can be formed from several words –rate, interestRate, interest_rate

Programming Logic and Design, Introductory, Fourth Edition22 Ending a Program by Using Sentinel Values Infinite loop: a sequence of statements that repeats forever with no escape Avoid infinite loops by testing for a predetermined value that means “stop processing” Decision: testing a value Flowchart decision symbol: a diamond shape, with two flowlines, one for Yes and one for No

Programming Logic and Design, Introductory, Fourth Edition23 Ending a Program by Using Sentinel Values (continued) Sentinel value (or dummy value) –Does not represent real data –Signal to stop –Can be used with input from files or from users End-of-file (EOF) marker: –Code stored in the file that marks the end of the data –Usually used instead of a sentinel value for file input

Programming Logic and Design, Introductory, Fourth Edition24 Using the Connector Flowchart connector symbol: –Marks a logic transfer to another location in the flowchart –Transfer location can be on the same page or on another page –On-page symbol: a circle with a number or letter to identify the matching transfer location –Off-page symbol: a square with a pointed bottom, containing page number and a number of letter to identify the matching transfer location

Programming Logic and Design, Introductory, Fourth Edition25 Using the Connector (continued)

Programming Logic and Design, Introductory, Fourth Edition26 Assigning Values to Variables Assignment statement: –Assigns a value to a variable –Variable must appear on the left side, value on the right side of the assignment operator –Right side may be an expression that will be evaluated before storing the value in the variable Assignment operator: the equal sign (=) in most languages Variable: –Memory location: has an address and a value –Value (contents) is used for various operations

Programming Logic and Design, Introductory, Fourth Edition27 Understanding Data Types Two basic data types: –Text –Numeric Numeric data stored by numeric variables Text data stored by string, text, or character variables Constants: –Values that do not change while the program is running –Have identifiers, and can be used like variables for calculations, but cannot be assigned new values

Programming Logic and Design, Introductory, Fourth Edition28 Understanding Data Types (continued) Some programming languages implement several numeric data types, such as: –Integer: whole numbers only –Floating-point: fractional numeric values with decimal points Character or string data is represented as characters enclosed in quotation marks –“x”, “color” Data types must be used appropriately

Programming Logic and Design, Introductory, Fourth Edition29 Understanding Data Types (continued)

Programming Logic and Design, Introductory, Fourth Edition30 Understanding the Evolution of Programming Techniques (continued) Two major programming techniques: –Procedural programming –Object-oriented programming Procedural programming: focuses on the procedures that programmers create Object-oriented programming: focuses on objects that represent real-world things and their attributes and behaviors Both techniques employ reusable program modules