Lecture 2 Problem Solving - PowerPoint PPT Presentation

1 / 35
About This Presentation
Title:

Lecture 2 Problem Solving

Description:

Lecture 2. Problem Solving. ENGR17: Engineering Programming. Section #1. Fall ... Hints for Writing Algorithms. 6/4/09. ENGR17: Engineering Programming. 15 ... – PowerPoint PPT presentation

Number of Views:212
Avg rating:3.0/5.0
Slides: 36
Provided by: jimand
Category:

less

Transcript and Presenter's Notes

Title: Lecture 2 Problem Solving


1
Lecture 2Problem Solving
  • ENGR17 Engineering Programming
  • Section 1
  • Fall 2001

9/11/01
2
Outline
  • Six problem-solving steps used to create a
    computer program
  • Complete an IPO chart
  • Plan an algorithm using pseudocode and flowcharts
  • Desk-check an algorithm
  • Code and execute the algorithm

3
Creating Computer Solutions
4
Analyzing the Problem
  • Determine the output(goal or purpose of solving
    the problem)
  • Determine the input(information needed to reach
    the goal)
  • Use an IPO (Input, Processing, Output) chart to
    organize and summarize the results of problem
    analysis

5
Analyzing the Problem
6
Analyzing the Problem
  • Most difficult problem-solving step
  • Problem specification can contain too much or too
    little information
  • Distinguish between information that is missing
    in the problem specification, and information
    that is not explicitly stated

7
Analyzing the Problem
8
IPO Chart
9
Analyzing the Problem
10
Planning the Algorithm
  • Algorithm the steps that will transform the
    input into the output
  • Enter input items
  • Process the data (usually by doing some
    calculations)
  • Print or display the output items
  • Tools
  • IPO chart
  • Pseudocode
  • Flowcharts

11
Planning the Algorithm
12
Pseudocode Flowcharts
  • Use standardized symbols, connected with
    flowlines, to show the steps the computer needs
    to take to accomplish the programs goal

Start/Stop
Process
Input/Output
13
(No Transcript)
14
Hints for Writing Algorithms
15
Hints for Writing Algorithms
16
Hints for Writing Algorithms
17
Hints for Writing Algorithms
18
Hints for Writing Algorithms
19
Desk-checking the Algorithm
  • Refers to completing each step in the algorithm
    manually, using a set of sample data for input
    values
  • Verifies that the algorithm is not missing steps
  • Verifies that the existing steps are correct and
    in the proper order
  • Also called hand-tracing
  • Can use a desk-check table

20
Desk-checking the Algorithm
21
Desk-checking the Algorithm
22
Desk-checking the Algorithm
23
Problem Solving Summary
  • Problem-solving steps used to create a computer
    program
  • Analyze the problem
  • Plan the algorithm
  • Desk-check the algorithm
  • Code the algorithm into a program
  • Desk-check the program
  • Evaluate and modify the program
  • IPO charts
  • Planning an algorithm using pseudocode and
    flowcharts
  • Desk-checking an algorithm

continued
24
Completing the Problem-Solving Process
25
The C Programming Language
  • Object-oriented successor to the
    procedure-oriented C language
  • C language
  • 1972, Dennis Ritchie, Bell Laboratories
  • C
  • 1985, Bjarne Stroustrup, Bell Laboratories
  • Can be used as a procedural as well as an
    object-oriented language

26
Requirements for Creating C Program
  • Text editor
  • Used to enter the C instructions (source code)
  • C compiler
  • Converts source code into machine code (object
    code)
  • Case sensitive

27
Different C Systems
  • Integrated Development Environment (IDE)
  • Contain editor and compiler in one integrated
    environment
  • Examples Microsoft Visual C, Borland C
    Builder
  • Command-line compilers
  • Contain only the compiler
  • Require use of general purpose editor (NotePad,
    WordPad) to enter program instructions

28
Coding the Algorithm
  • Coded algorithm a program
  • Starting Microsoft Visual C 5.0

29
Program Instructions
30
C Programs
  • Use a precise syntax
  • Can include comments (//)
  • Contain at least one directive
  • Must contain a function named main

31
Other Coding Terminology
  • Header files (.h)
  • Keywords
  • Functions and void functions ( and )
  • Variables
  • Statements ()
  • Streams (cout and cin)
  • Insertion operators (()
  • Stream manipulators

32
Evaluating and Modifying the Program
  • Testing
  • Execute the program and enter sample data
  • Valid data
  • Invalid data
  • Debugging
  • Locate and remove errors in a program
  • Syntax error
  • Logic error

33
Executing a C Program
  • Before it can be executed, a C program must be
    compiled (source code translated into object code)

34
After Completing Program
  • Assemble external documentation and keep in a
    safe place
  • IPO chart
  • Flowchart of pseudocode
  • Printout of the program

35
Programming Summary
  • Origins of the C programming language
  • Source code and object code
  • Opening a C source file
  • Coding an algorithm
  • Compiling, building, and executing a C program
  • Evaluating and modifying a program
Write a Comment
User Comments (0)
About PowerShow.com