Presentation is loading. Please wait.

Presentation is loading. Please wait.

How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.

Similar presentations


Presentation on theme: "How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5."— Presentation transcript:

1 How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5

2 Problem Solving Is an art, not a science It must be experienced, it can't be taught –Guidelines can be provided Based on experience Sound like platitudes Are internalized as we learn to solve problems It requires patience

3 Problem Solving Tasks Establish the context of the problem –Understand the problem –Determine the primary goals of the solution –Create a solution

4 Problem Solving Guidelines One big problem is unsolvable –Many small problems can be managed Understand the problem: What is needed? –Write on paper what results are expected –What functions (procedures) will be required to generate these results –What information will need to be given to these functions –Describe what the functions do before you write a single line of code

5 Programs A program is a set of step-by-step instructions that directs the computer to do the tasks you want it to do and produce the results you want.

6 The Program Development Cycle

7 Understand the problem Become familiar with what the program is trying to accomplish –Read the specifications –Ask questions –Understand the specifications Eliminate extraneous information

8 Analyze Determine inputs –·Variable NAMES –·Variable TYPES –·Ranges of VALUES Names and types of OBJECTS in appropriate. Determine outputs –·Output Values –·Indicate VARIABLE NAMES to store output values –·Determine VARIABLE TYPE of output variables

9 Plan the Program’s Logic Decide how to best meet the program’s specifications Often uses a flowchart or pseudocode Divide the program into subroutines, functions or modules –Subroutines cost less and take less time to maintain –Can be used in other programs –Several programmers can work on the same project

10 Develop a Solution Create a FLOW CHART based on mapping Test flow chart for RELIABILITY - all inputs produce proper output Write PSEUDO CODE based on flow chart –Test flow chart for reliability.

11 Code the Program Put the solution, generally documented with pseudocode or a flowchart into a programming language CODE the solution –Select an appropriate language (C++) –Code the pseudo code –Create a user interface if required

12 Machine-Readable Form Key the program into a computer

13 Translate the program Translated into machine language using an assembler, a compiler or an interpreter Includes the elimination of syntax errors Generate executable file

14 Test the Program Logic errors are not listed during the translation projects Only way to find logic errors is to do program testing –Involves using sample data as input –Executing the program –Checking the results manually Know as debugging

15 Planning Your Tests Create an input file that tests all input ranges –If there are independent input values, test all values –If there are ranges of input values, test the middle of each range, and the upper and lower bounds on each range break –For example, of the range is integers from 1 to 10, check: 5 1 0 10 11

16 Document the Program Internal Documentation –Comments External Documentation –Program specification –Layout chart –Hierarchy chart –Program flowchart –Pseudo-code –Data Dictionary Input, Output, Work Area Name, description, type, initial value, calculation –Source listing –Test Plan

17 Programming Languages A programming language is a set of rules that provides a way of telling a computer what operations to perform.

18 Levels of Programming Languages Machine language Assembly Language High Level Languages Fourth Generation Languages (4GL)

19 Fundamental Programming Concepts Assignment of values to a variable Iteration (Looping) –Over a set of set of statements –With respect to a logical expressions (conditions) Delegation of sub-tasks to functions / procedures


Download ppt "How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5."

Similar presentations


Ads by Google