Programming Logic and Design Fifth Edition, Comprehensive

Slides:



Advertisements
Similar presentations
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Advertisements

Lecture 1: Overview of Computers & Programming
CHAPTER 1: AN OVERVIEW OF COMPUTERS AND LOGIC. Objectives 2  Understand computer components and operations  Describe the steps involved in the programming.
Programming Logic and Design Fourth Edition, Introductory
Starting Out with C++, 3 rd Edition 1 Chapter 1. Introduction to Computers and Programming.
COSC 120 Computer Programming
Chapter 1 An Overview of Computers and Logic
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.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Sixth Edition by Tony Gaddis, Judy Walters,
An Overview of Computers and Logic
An Overview of Programming Logic and Design
Modules, Hierarchy Charts, and Documentation
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
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
An Overview of Computers and Programming
Chapter 1: Introduction To Computer | SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005 Slide 1 Introduction To Computers.
CS102 Introduction to Computer Programming
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Chapter Introduction to Computers and Programming 1.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
An Overview of Computers and Logic
Structured COBOL Programming, Stern & Stern, 9th edition
1 CSC103: Introduction to Computer and Programming Lecture No 2.
Topics Introduction Hardware and Software How Computers Store Data
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.
CIS Computer Programming Logic
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
S2008Final_part1.ppt CS11 Introduction to Programming Final Exam Part 1 S A computer is a mechanical or electrical device which stores, retrieves,
P ROGRAMMING L OGIC AND D ESIGN S IXTH E DITION Chapter 1 An Overview of Computers and Programming.
An Object-Oriented Approach to Programming Logic and Design Chapter 1 An Overview of Computers and Logic.
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.
CHAPTER 1 INTRODUCTION 2 nd Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Programming Logic and Design Seventh Edition
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.
Digital Literacy: Computer Basics
Brief Version of Starting Out with C++ Chapter 1 Introduction to Computers and Programming.
1. COMPUTERS AND PROGRAMS Rocky K. C. Chang September 6, 2015 (Adapted from John Zelle’s slides)
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
CHAPTER 1 OVERVIEW OF COMPUTER AND PROGRAMMING 1.1 Electronic Computer Then and Now 1.2 Computer Hardware 1.3 Computer Software 1.4 The Software Development.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
Chapter 1: Introduction to Computers and Programming
Chapter 1 Introduction 2nd Semester H
DDC 1023 – Programming Technique
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 2 Applications and Data.
Chapter 1: Introduction to Computers and Programming
Topics Introduction Hardware and Software How Computers Store Data
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Data Groupings: File File: a group of related records
Chapter 4: Writing and Designing a Complete Program
Programming Logic and Design Eighth Edition
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

Programming Logic and Design Fifth Edition, Comprehensive Chapter 1 An Overview of Computers and Logic

Objectives Understand computer components and operations Learn about the steps involved in the programming process Learn about the data hierarchy and file input Use flowchart symbols and pseudocode statements Use and name variables Programming Logic and Design, Fifth Edition, Comprehensive

Objectives (continued) Use a sentinel, or dummy value, to end a program Manage large flowcharts Assign values to variables Recognize the proper format of assignment statements Describe data types Understand the evolution of programming techniques Programming Logic and Design, Fifth Edition, Comprehensive

Understanding Computer Components and Operations Hardware and software: the two major components of any computer system Hardware: equipment, or devices Software: programs that contain instructions for the computer Four major operations in a computer: Input Processing Output Storage Programming Logic and Design, Fifth Edition, Comprehensive

Understanding Computer Components and Operations (continued) Input devices: allow data to enter the computer Mouse, keyboard, scanner Processing: working on the data Organizing data Checking data for accuracy Mathematical or other manipulations on data Central Processing Unit (CPU): hardware that performs the tasks Programming Logic and Design, Fifth Edition, Comprehensive

Understanding Computer Components and Operations (continued) Output devices: provide data to the user Printer, monitor, speakers Programming language: special language containing instructions for the computer Visual Basic, Java, C#, C++, COBOL Syntax: rules governing word usage and punctuation in the language Programming Logic and Design, Fifth Edition, Comprehensive

Understanding Computer Components and Operations (continued) Machine language: controls the computer’s on/off circuitry Compiler or interpreter: software that translates programming languages to machine language Program must be free of syntax errors to be run, or executed, on a computer To function properly, the logic must be correct Programming Logic and Design, Fifth Edition, Comprehensive

Understanding Computer Components and Operations (continued) What is wrong with this logic for making a cake? Stir Add two eggs Bake at 350 degrees for 45 minutes Add three cups of flour Programming Logic and Design, Fifth Edition, Comprehensive

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) Get input number. Compute calculated answer as inputNumber times 2. Print calculatedAnswer. Programming Logic and Design, Fifth Edition, Comprehensive

Understanding Computer Components and Operations (continued) Two storage categories: internal and external Internal storage: Main memory, random access memory (RAM) Located inside the computer system Volatile: contents are lost when power goes down External storage: Persistent: contents are relatively permanent Floppy drive, hard drive, flash media, magnetic tape Located outside the computer system Programming Logic and Design, Fifth Edition, Comprehensive

Understanding the Programming Process Six programming phases: Understand the problem Plan the logic Code the program Use software to translate the program to machine language Test the program Put the program into production Programming Logic and Design, Fifth Edition, Comprehensive

Understanding 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 Programming Logic and Design, Fifth Edition, Comprehensive

Planning the Logic Plan the steps that the program will take Use tools such as flowcharts and pseudocode Flowchart: a pictorial representation of the logic steps Pseudocode: Natural language representation of the logic Walk through the logic before coding by desk-checking the logic Programming Logic and Design, Fifth Edition, Comprehensive

Coding the Program Select the programming language Some languages more efficient for certain tasks All languages handle input, arithmetic processing, output, other standard functions Logic can be executed in any number of languages Write the instructions Planning generally more difficult than coding Programming Logic and Design, Fifth Edition, Comprehensive

Using Software to Translate the Program into Machine Language Programmers write instructions in high-level languages that resemble a natural language Compilers or interpreters change the programs into a low-level machine language that can be executed Syntax errors are identified by the compiler or interpreter Programming Logic and Design, Fifth Edition, Comprehensive

Figure 1-1 Creating an executable program Using Software to Translate the Program into Machine Language (continued) Figure 1-1 Creating an executable program Programming Logic and Design, Fifth Edition, Comprehensive

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 Programming Logic and Design, Fifth Edition, Comprehensive

Putting the Program into Production Might mean simply running the program once Process might take months if program is used on regular basis or is part of larger development Train data-entry people and users Change existing data Conversion: entire set of actions organization must take to switch over to new program(s) Programming Logic and Design, Fifth Edition, Comprehensive

Understanding Interactive User Input Prompt: message displayed on a monitor Asks the user for a response Command prompt: location to type entries to communicate with the operating system Graphical User Interface (GUI): allows users to interact with a program in a graphical environment Programming Logic and Design, Fifth Edition, Comprehensive

Understanding Interactive User Input (continued) Figure 1-2 A prompt, response, and output in a command line environment Programming Logic and Design, Fifth Edition, Comprehensive

Understanding Interactive User Input (continued) Figure 1-3 A prompt, response, and output in a GUI environment Programming Logic and Design, Fifth Edition, Comprehensive

Understanding the Data Hierarchy and File Input Data hierarchy: ordering of data types by size Character: single 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, Fifth Edition, Comprehensive

Understanding the Data Hierarchy and File Input (continued) Figure 1-4 The data hierarchy Programming Logic and Design, Fifth Edition, Comprehensive

Understanding the Data Hierarchy and File Input (continued) Figure 1-5 The EMPLOYEE file represented as a stack of index cards Programming Logic and Design, Fifth Edition, Comprehensive

Using Flowchart Symbols and Pseudocode Statements Flowchart: pictorial representation of the logic Pseudocode: English-like representation of the logic Example: start get inputNumber compute calculatedAnswer as inputNumber times 2 print calculatedAnswer stop Programming Logic and Design, Fifth Edition, Comprehensive

Using Flowchart Symbols and Pseudocode Statements (continued) Figure 1-6 Input symbol Programming Logic and Design, Fifth Edition, Comprehensive

Using Flowchart Symbols and Pseudocode Statements (continued) Figure 1-7 Processing symbol Programming Logic and Design, Fifth Edition, Comprehensive

Using Flowchart Symbols and Pseudocode Statements (continued) Figure 1-8 Output symbol Programming Logic and Design, Fifth Edition, Comprehensive

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, Fifth Edition, Comprehensive

Using Flowchart Symbols and Pseudocode Statements (continued) Figure 1-9 Flowchart and pseudocode of program that doubles a number Programming Logic and Design, Fifth Edition, Comprehensive

Using Flowchart Symbols and Pseudocode Statements (continued) Figure 1-10 Inefficient pseudocode for program that doubles 10,000 numbers Programming Logic and Design, Fifth Edition, Comprehensive

Using Flowchart Symbols and Pseudocode Statements (continued) Figure 1-11 Flowchart of infinite number-doubling program Programming Logic and Design, Fifth Edition, Comprehensive

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

Using and Naming Variables (continued) Choose meaningful names for variables Improves the readability and maintainability of code Table 1-1 Suitability of suggested variable names for an employee’s last name Programming Logic and Design, Fifth Edition, Comprehensive

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, Fifth Edition, Comprehensive

Ending a Program by Using Sentinel Values (continued) Figure 1-12 Flowchart of number-doubling program with sentinel value of 0 Programming Logic and Design, Fifth Edition, Comprehensive

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, Fifth Edition, Comprehensive

Ending a Program by Using Sentinel Values (continued) Figure 1-13 Flowchart using eof Programming Logic and Design, Fifth Edition, Comprehensive

Managing Large Flowcharts 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, Fifth Edition, Comprehensive

Managing Large Flowcharts (continued) Figure 1-14 Flowchart using the connector Programming Logic and Design, Fifth Edition, Comprehensive

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, Fifth Edition, Comprehensive

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, Fifth Edition, Comprehensive

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, Fifth Edition, Comprehensive

Understanding Data Types (continued) Table 1-2 Some examples of legal and illegal assignments Programming Logic and Design, Fifth Edition, Comprehensive

Understanding the Evolution of Programming Techniques Programming began in the 1940s, using memory addresses and machine code directly Higher-level languages were developed to allow English-like instructions Older programs were “monolithic,” and ran from beginning to end Newer programs contain modules that can be combined to form programs Programming Logic and Design, Fifth Edition, Comprehensive

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 Programming Logic and Design, Fifth Edition, Comprehensive

Summary Four major computer operations: Six programming phases: Input Processing Output Storage Six programming phases: Understand the problem Plan the logic Code the program Translate the program to machine language Test the program Deploy the program Programming Logic and Design, Fifth Edition, Comprehensive

Summary (continued) Data hierarchy: Character Field Record File Database Flowchart: pictorial representation of program logic Variables: named memory locations that contain values Programming Logic and Design, Fifth Edition, Comprehensive

Summary (continued) Testing a value involves making a decision Assignment statements: store a value into a variable Assignment operator: the equal (=) sign in most languages Programming Logic and Design, Fifth Edition, Comprehensive

Summary (continued) Two major data types: text and numeric Procedural programming: focuses on actions performed on data Object-oriented programming: focuses on representing and manipulating objects Programming Logic and Design, Fifth Edition, Comprehensive