SlideShare a Scribd company logo
Programming Logic and Design  Fourth Edition, Comprehensive   Chapter 1 An Overview of Computers and Logic
Objectives Understand computer components and operations  Describe the steps involved in the programming process Describe the data hierarchy Understand how to use flowchart symbols and pseudocode statements Use and name variables
Objectives (continued) Use a sentinel, or dummy value, to end a program Use a connector symbol Assign values to variables Recognize the proper format of assignment statements Describe data types Understand the evolution of programming techniques
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
Understanding Computer Components and Operations (continued) Input devices : allow data to enter the computer Mouse, keyboard, scanner Processing : working on the data; such as: Organizing data  Checking data for accuracy  Mathematical or other manipulations on data Central Processing Unit (CPU) : hardware that performs the tasks
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 : the rules governing word usage and punctuation in the language Machine language : a language that controls the computer’s on/off circuitry Compiler  or  interpreter : software that translates programming languages to machine language
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?
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)
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 V olatile : contents are lost when power goes down External storage : P ersistent : contents are relatively permanent Floppy drive, hard drive, flash media, magnetic tape Located outside the computer system
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 Deploy the program into production
Understanding the Programming Process (continued) 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
Understanding the Programming Process (continued) 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 : English-like representation of the logic Walk through the logic before coding by  desk-checking  the logic
Understanding the Programming Process (continued) Coding the program: 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
Understanding the Programming Process (continued)
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
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
Understanding the Data Hierarchy (continued)
Using Flowchart Symbols and Pseudocode Statements Flowchart : pictorial representation of the logic Pseudocode : English-like representation of the logic Example:
Using Flowchart Symbols and Pseudocode Statements (continued) Flowchart  input symbol :
Using Flowchart Symbols and Pseudocode Statements (continued) Flowchart  processing symbol
Using Flowchart Symbols and Pseudocode Statements (continued) Flowchart  output symbol :
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
Using Flowchart Symbols and Pseudocode Statements (continued)
Using Flowchart Symbols and Pseudocode Statements (continued) Back-pointing arrows show statements that will be repeated
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
Using and Naming Variables (continued) Choose meaningful names for variables Improves the readability and maintainability of code
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
Ending a Program by Using Sentinel Values (continued)
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
Ending a Program by Using Sentinel Values (continued)
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
Using the Connector (continued)
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
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
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
Understanding Data Types (continued)
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
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
Summary Four major computer operations: input, processing, output, and 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 Data hierarchy: character -> field -> record -> file -> database Flowchart: pictorial representation of program logic Variables: named memory locations that contain values
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 Two major data types: text and numeric Procedural programming focuses on actions performed on data Object-oriented programming focuses on representing and manipulation objects

More Related Content

PPTX
Flowcharts and algorithms
PPTX
Algorithms, flow charts and pseudocodes
PPTX
pseudocode and Flowchart
PPT
Programming
PPSX
Algorithm and flowchart
PPTX
Operating Systems - Processor Management
PPTX
Programming Fundamentals lecture 1
Flowcharts and algorithms
Algorithms, flow charts and pseudocodes
pseudocode and Flowchart
Programming
Algorithm and flowchart
Operating Systems - Processor Management
Programming Fundamentals lecture 1

What's hot (20)

PPTX
Algorithm and pseudo codes
PPTX
Programming languages
PPTX
Introduction to flowchart
PDF
Deadlock Avoidance - OS
PPTX
Operating system || Chapter 1: Introduction
PPT
Programming aids- Algorithm, Flowchart, Pseudocodes and Decision table
PPT
Computer Essentials
PPTX
Basic of computer
PPT
Input devices_(Mouse and Keyboard)
PPTX
Lesson 6 printing
PPTX
Flowchart and algorithm
PDF
Algorithms Lecture 1: Introduction to Algorithms
PDF
Operating System.pdf
PPTX
Process in operating system
PPTX
Types of Programming Languages
PPT
Introduction to qbasic
PPT
Computer System Organization
PPTX
Algorithm and flowchart
PDF
Unit 1 introduction to operating system
Algorithm and pseudo codes
Programming languages
Introduction to flowchart
Deadlock Avoidance - OS
Operating system || Chapter 1: Introduction
Programming aids- Algorithm, Flowchart, Pseudocodes and Decision table
Computer Essentials
Basic of computer
Input devices_(Mouse and Keyboard)
Lesson 6 printing
Flowchart and algorithm
Algorithms Lecture 1: Introduction to Algorithms
Operating System.pdf
Process in operating system
Types of Programming Languages
Introduction to qbasic
Computer System Organization
Algorithm and flowchart
Unit 1 introduction to operating system
Ad

Viewers also liked (6)

PPTX
Programming Logic and Design: Working with Data
PPT
Logic Formulation 3
PPT
Csharp4 basics
PPT
Komunikasyon
PPTX
Dynamic Programming
PPTX
Minto pyramid
Programming Logic and Design: Working with Data
Logic Formulation 3
Csharp4 basics
Komunikasyon
Dynamic Programming
Minto pyramid
Ad

Similar to Introduction to Programming (20)

PPT
Cs111 ch01 v4
PPT
Chapter 5( programming) answer
PPT
01. introduction
PPT
01. Introduction.ppt
PPT
Program logic and design
PPTX
UNIT 2 ECSE-2.pptx
PPT
Cpcs302 1
PPT
Software development slides
PPT
Chapter One
PDF
ArduinoWorkshop2.pdf
PDF
Compilers Principles, Practice & Tools Compilers
PPTX
Computer and programing basics.pptx
PPT
FINAL.ppt
PPTX
unit1_cd unit1_cd unit1_cd unit1_cd unit1_cd (1).pptx
PPT
Compiler Construction introduction
PPT
Compiler design computer science engineering.ppt
PPTX
A Lecture of Compiler Design Subject.pptx
PPTX
INTRODUCCIÓN A LA PROGRAMACIÓN
DOC
Programming content
Cs111 ch01 v4
Chapter 5( programming) answer
01. introduction
01. Introduction.ppt
Program logic and design
UNIT 2 ECSE-2.pptx
Cpcs302 1
Software development slides
Chapter One
ArduinoWorkshop2.pdf
Compilers Principles, Practice & Tools Compilers
Computer and programing basics.pptx
FINAL.ppt
unit1_cd unit1_cd unit1_cd unit1_cd unit1_cd (1).pptx
Compiler Construction introduction
Compiler design computer science engineering.ppt
A Lecture of Compiler Design Subject.pptx
INTRODUCCIÓN A LA PROGRAMACIÓN
Programming content

More from Chaffey College (20)

PPT
Strings Objects Variables
PPT
Ruby Chapter 2
PPTX
Social networks and games
PPT
Serious games
PPT
Chapter 05
PPT
Chapter 04
PPT
Chapter 03
PPTX
The games factory 2 alien wars
PPTX
Target markets
PPT
Ch 8 introduction to data structures
PPT
Ch 8 data structures in alice
PPT
Ch 7 recursion
PPTX
Intro to gml
PPT
Power point unit d
PPT
Power point unit c
PPT
Power point unit b
PPT
Power point unit a
PPT
Gamegraphics
PPT
Gamesound
PPT
Ch 6 text and sound in alice
Strings Objects Variables
Ruby Chapter 2
Social networks and games
Serious games
Chapter 05
Chapter 04
Chapter 03
The games factory 2 alien wars
Target markets
Ch 8 introduction to data structures
Ch 8 data structures in alice
Ch 7 recursion
Intro to gml
Power point unit d
Power point unit c
Power point unit b
Power point unit a
Gamegraphics
Gamesound
Ch 6 text and sound in alice

Introduction to Programming

  • 1. Programming Logic and Design Fourth Edition, Comprehensive Chapter 1 An Overview of Computers and Logic
  • 2. Objectives Understand computer components and operations Describe the steps involved in the programming process Describe the data hierarchy Understand how to use flowchart symbols and pseudocode statements Use and name variables
  • 3. Objectives (continued) Use a sentinel, or dummy value, to end a program Use a connector symbol Assign values to variables Recognize the proper format of assignment statements Describe data types Understand the evolution of programming techniques
  • 4. 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
  • 5. Understanding Computer Components and Operations (continued) Input devices : allow data to enter the computer Mouse, keyboard, scanner Processing : working on the data; such as: Organizing data Checking data for accuracy Mathematical or other manipulations on data Central Processing Unit (CPU) : hardware that performs the tasks
  • 6. 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 : the rules governing word usage and punctuation in the language Machine language : a language that controls the computer’s on/off circuitry Compiler or interpreter : software that translates programming languages to machine language
  • 7. 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?
  • 8. 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)
  • 9. 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 V olatile : contents are lost when power goes down External storage : P ersistent : contents are relatively permanent Floppy drive, hard drive, flash media, magnetic tape Located outside the computer system
  • 10. 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 Deploy the program into production
  • 11. Understanding the Programming Process (continued) 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
  • 12. Understanding the Programming Process (continued) 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 : English-like representation of the logic Walk through the logic before coding by desk-checking the logic
  • 13. Understanding the Programming Process (continued) Coding the program: 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
  • 14. Understanding the Programming Process (continued)
  • 15. 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
  • 16. 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
  • 17. Understanding the Data Hierarchy (continued)
  • 18. Using Flowchart Symbols and Pseudocode Statements Flowchart : pictorial representation of the logic Pseudocode : English-like representation of the logic Example:
  • 19. Using Flowchart Symbols and Pseudocode Statements (continued) Flowchart input symbol :
  • 20. Using Flowchart Symbols and Pseudocode Statements (continued) Flowchart processing symbol
  • 21. Using Flowchart Symbols and Pseudocode Statements (continued) Flowchart output symbol :
  • 22. 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
  • 23. Using Flowchart Symbols and Pseudocode Statements (continued)
  • 24. Using Flowchart Symbols and Pseudocode Statements (continued) Back-pointing arrows show statements that will be repeated
  • 25. 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
  • 26. Using and Naming Variables (continued) Choose meaningful names for variables Improves the readability and maintainability of code
  • 27. 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
  • 28. Ending a Program by Using Sentinel Values (continued)
  • 29. 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
  • 30. Ending a Program by Using Sentinel Values (continued)
  • 31. 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
  • 32. Using the Connector (continued)
  • 33. 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
  • 34. 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
  • 35. 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
  • 37. 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
  • 38. 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
  • 39. Summary Four major computer operations: input, processing, output, and 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 Data hierarchy: character -> field -> record -> file -> database Flowchart: pictorial representation of program logic Variables: named memory locations that contain values
  • 40. 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 Two major data types: text and numeric Procedural programming focuses on actions performed on data Object-oriented programming focuses on representing and manipulation objects