Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 11: 10/1/2002CS149D Fall 20021 CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.

Similar presentations


Presentation on theme: "Lecture 11: 10/1/2002CS149D Fall 20021 CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture."— Presentation transcript:

1 Lecture 11: 10/1/2002CS149D Fall 20021 CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture 11: 10/1/2002

2 CS149D Fall 20022 Outline Skip section 3.6 and 3.7 Overview of Computer Programming Process Overview of algorithms and programming languages Should cover section 4.1 from Brookshear Text, and sections 1.1- 1.2 from Etter Text

3 Lecture 11: 10/1/2002CS149D Fall 20023 Computer Programming Computer program A sequence of instructions to be performed by a computer Computer programming The process of planning a sequence of steps for a computer to follow Programming Process Problem-solving phase Implementation phase Maintenance phase

4 Lecture 11: 10/1/2002CS149D Fall 20024 Programming Process 1/3 Problem-solving phase Analysis and specification ( understand and define problem, and what is expected of solution) General solution (algorithm: a logical sequence of steps that solves the problem) Verification (Follow steps to make sure solution solves the problem) Implementation phase Concrete solution (Program in a Programming language) Testing (make sure the program produces the desired results) Maintenance phase Use Program Maintain Program (meet changing requirements)

5 Lecture 11: 10/1/2002CS149D Fall 20025 Programming Process 2/3 Analysis and Specification General solution (algorithm) Verification Concrete solution (Program) Testing Maintenance Phase In “Programming and Problem Solving with C++”, 3 rd Edition, Jones and Bartlett Publishers, 2002 Documentation: writing program documentation, and user manuals

6 Lecture 11: 10/1/2002CS149D Fall 20026 Programming Process 3/3 How about we take a shortcut and start the programming process by the implementation phase? Costly shortcut Develop a general solution (algorithm) first Think first and code later!

7 Lecture 11: 10/1/2002CS149D Fall 20027 Algorithm 1/3 Algorithm An ordered set of unambiguous executable steps, defining a terminating process A step-by-step procedure for solving a problem in a finite amount of time 1.Make a list of all positive integers 2.Arrange the list in descending order (from largest to smallest) 3.Extract the first integer from the list What are the problems with these instructions?

8 Lecture 11: 10/1/2002CS149D Fall 20028 Algorithm 2/3 Difference between an algorithm and its representation Analogous to difference between a story and a book An algorithm is abstract and can be represented in many ways Algorithm for converting from Celsius to Fahrenheit can be represented as 1. F = (9/5) C + 32 (algebraic equation) 2. “ Multiply the temperature reading in Celsius by 9/5 and then add 32 to the product” An algorithm can be represented using some sort of language 1950s, 1960s  represented using flowcharts pseudocode (precisely defined textual structures)

9 Lecture 11: 10/1/2002CS149D Fall 20029 Algorithm 3/3 An algorithm for starting the car 1.Insert the key in ignition 2.Make sure transmission is in Park (or Neutral) 3.Depress the gas pedal 4.Turn key to start position 5.If engine starts within six seconds, release key to ignition position 6.If engine does not start in six seconds, release key and gas pedal, wait ten seconds, and repeat steps 3 through 6, but not more than five times 7.If the car does not start, call the garage

10 Lecture 11: 10/1/2002CS149D Fall 200210 Programming Language 1/3 A set of rules, symbols, and special words used to construct a computer program. There are rules for syntax (grammar) and semantics (meaning) Machine language Binary-coded instructions Closely coupled with design of computer hardware Assembly language Low-level programming language in which a mnemonic is used to represent each of the machine language instructions We have seen an example in chapter 2 from Brookshear Text We need an assembler Translate an assembly language program into machine code

11 Lecture 11: 10/1/2002CS149D Fall 200211 Programming Language 2/3 High-level language closer to English and other natural languages C++, Java, C, Fortran, Ada, Pascal, COBOL, BASIC We need a compiler Translate a high-level language program into machine code Source program Program written in a high-level language Object program Machine language version of a source program Difference between compilation and execution of a program

12 Lecture 11: 10/1/2002CS149D Fall 200212 Programming Language 3/3 Some programming languages are translated by an interpreter (some versions of BASIC) Interpreter translates and executes each instruction in the source program Java uses both a compiler and interpreter


Download ppt "Lecture 11: 10/1/2002CS149D Fall 20021 CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture."

Similar presentations


Ads by Google