Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © Prentice Hall 20001 Programming and Languages Chapter 14 Telling the Computer What to Do.

Similar presentations


Presentation on theme: "Copyright © Prentice Hall 20001 Programming and Languages Chapter 14 Telling the Computer What to Do."— Presentation transcript:

1 Copyright © Prentice Hall 20001 Programming and Languages Chapter 14 Telling the Computer What to Do

2 Copyright © Prentice Hall 20002 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.

3 Copyright © Prentice Hall 20003 Programming Languages A programming language is a set of rules that provides a way of telling a computer what operations to perform.

4 Copyright © Prentice Hall 20004 Programmers A programmer’s job is to convert problem solutions into instructions for the computer. If the project is large, they may also need to coordinate the needs of users, managers, and systems managers.

5 Copyright © Prentice Hall 20005 The Programming Process The steps involved in developing a program include: Define the problemDefine the problem Plan the solutionPlan the solution Code the programCode the program Test the programTest the program Document the programDocument the program

6 Copyright © Prentice Hall 20006 Define the Problem The task of defining the problem consists of identifying what it is you know and what it is you want to obtain.

7 Copyright © Prentice Hall 20007 Plan the Solution Planning the solution may involve drawing a flowchart or writing pseudocode, or both.

8 Copyright © Prentice Hall 20008 Flowcharts A flowchart is a pictorial representation of a step-by-step solution to a problem.

9 Copyright © Prentice Hall 20009 Flowchart Basics A flowchart consists of arrows to represent direction the program takes and boxes and symbols to represent actions.

10 Copyright © Prentice Hall 200010 Flowchart Symbols ProcessStart/Stop Input/Output Decision Connector Flow direction

11 Copyright © Prentice Hall 200011 Pseudocode Pseudocode is an English-like nonstandard language. It allows programmers to focus on the program logic without being concerned about the particulars of a formal programming language.

12 Copyright © Prentice Hall 200012 Code the Program Coding a program means to translate the logic from a flowchart of pseudocode into a programming language. The rules of computer languages are called syntax. These rules must be followed precisely.

13 Copyright © Prentice Hall 200013 Test the Program After coding, tests must be performed to make sure the steps are correct and render the desired results. Testing includes: Desk-checkingDesk-checking TranslatingTranslating DebuggingDebugging

14 Copyright © Prentice Hall 200014 Desk-checking This form of testing involves mentally checking the logic of the program to ensure that it is error-free and workable.

15 Copyright © Prentice Hall 200015 Translating Programs are commonly translated by a compiler which checks for syntax errors and converts the program into a form the computer understands.

16 Copyright © Prentice Hall 200016 Debugging Debugging means to detect, locate, and correct mistakes in the program. To find errors, you must test every part of the program under various conditions.

17 Copyright © Prentice Hall 200017 Document the Program A programmer must document the various stages the program has gone through as well as other specific facts about the program.

18 Copyright © Prentice Hall 200018 Levels of Programming Languages There are several levels (or “generations”) of programming languages: MachineMachine AssemblyAssembly High-levelHigh-level Very high-levelVery high-level NaturalNatural

19 Copyright © Prentice Hall 200019 First Generation: Machine Language This is the lowest level of programming language because it represents data and program instructions as 0s and 1s. All programming languages are eventually converted into machine language.

20 Copyright © Prentice Hall 200020 Second Generation: Assembly Language Assembly languages replace 0s and 1s with mnemonic codes. Since machine language is the only language the computer can execute, assembly is eventually translated into machine language to execute the program.

21 Copyright © Prentice Hall 200021 Third Generation: High-Level Language High-level languages use English-like words that are much easier for humans to understand. A translator is needed to convert the high-level language into machine language that computers understand.

22 Copyright © Prentice Hall 200022 Fourth Generation: Very High-Level Language This generation of language is often known as 4GLs. 4GLs are a shorthand programming language that is about 10 times more productive than third generation languages.

23 Copyright © Prentice Hall 200023 Fifth Generation: Natural Language This generation of programming languages more resembles “natural” spoken English. The user communicates with the computer by speaking.

24 Copyright © Prentice Hall 200024 Major Programming Languages There are several languages with which to write your program: FORTRAN FORTRAN COBOL COBOL BASIC BASIC Pascal Pascal C C Java Java Object-Oriented Object-Oriented

25 Copyright © Prentice Hall 200025 FORTRAN FORTRAN is a scientifically oriented language designed to execute complex formulas as in economic analysis and engineering.

26 Copyright © Prentice Hall 200026 COBOL COBOL was designed for business needs such as processing large files and performing business calculations.

27 Copyright © Prentice Hall 200027 BASIC This programming language is designed to be easy to learn. BASIC can be used for business applications and for use with personal computers.

28 Copyright © Prentice Hall 200028 Pascal Pascal was developed as a teaching language for computer students.

29 Copyright © Prentice Hall 200029 C C was originally developed to write systems software but is now considered a general-purpose language.

30 Copyright © Prentice Hall 200030 Java Java is a network- friendly programming language that permits a piece of software to run on many different platforms.

31 Copyright © Prentice Hall 200031 Object-Oriented Object-oriented programming is based on objects and their attributes.

32 Copyright © Prentice Hall 200032 Object Classes An object is a self-contained unit that contains both data and related facts and functions. Objects are arranged hierarchically in classes and subclasses based on their dominant characteristics.

33 Copyright © Prentice Hall 200033 Attributes and Methods Facts related to an object are called attributes. Methods are the instructions that tell the data what to do.

34 Copyright © Prentice Hall 200034 Object Inheritance An object in a subclass automatically possesses all the characteristics of the class from which it is derived.

35 Copyright © Prentice Hall 200035 Object-Oriented Languages There is an object-oriented version of C, called C++. Versions of C++ are available for large and personal computers. Smalltalk supports a visual system of programming. Text is entered with a keyboard but all other interaction takes place with mouse and icons.

36 Copyright © Prentice Hall 200036 Advantages of Object- Oriented Programming In a programming environment, a programmer does not have to repeat the instructions for “inherited” characteristics. This means a savings in time and money.

37 Copyright © Prentice Hall 200037 Sample Programs The following five slides demonstrate the syntax and structure of high- level programming languages. Only segments of an entire program are shown. Can you “guess” what each line in the program will do?

38 Copyright © Prentice Hall 200038 Fortran … WRITE (6,10) SUM=0 COUNTER = 0 WRITE (6,60) READ (5,40) NUMBER 1IF (NUMBER.EQ. 999) GOTO 2 SUM = SUM + NUMBER GOTO 1 …

39 Copyright © Prentice Hall 200039 COBOL …300-INITIALIZATION-ROUTINE. DISPLAY “PLEASE ENTER A NUMBER”. ACCEPT NUMBER-ITEM. 400-ENTER-AND-ADD. ADD NUMBER-ITEM TO SUM-ITEM. ADD 1 TO COUNTER. DISPLAY “PLEASE ENTER NEXT NUMBER” …

40 Copyright © Prentice Hall 200040 BASIC … SUM = 0 COUNTER = 0 PRINT “PLEASE ENTER A NUMBER” INPUT NUMBER DO WHILE NUMBER <> 999 SUM = SUM + NUMBER COUNTER = COUNTER + 1 …

41 Copyright © Prentice Hall 200041 Pascal …BEGIN sum :=0; counter :=0; WRITELN (‘PLEASE ENTER A NUMBER’); READLN (number); WHILE number <> 999 DO Begin (*while loop*) sum := sum + number; …

42 Copyright © Prentice Hall 200042 C++ … cout << “PLEASE ENTER A NUMBER”; cin>> number; while (number !=999) { sum := sum + number; sum := sum + number; counter ++; counter ++; cout <<“\nPlease enter the next number”; cout <<“\nPlease enter the next number”;…

43 Copyright © Prentice Hall 200043 Learning OOP Read booksRead books Use the tutorialsUse the tutorials Study sample codeStudy sample code Write OO codeWrite OO code Start smallStart small Use the help fileUse the help file Use your time productivelyUse your time productively

44 Copyright © Prentice Hall 200044 Conclusion Programming languages have evolved along with the hardware they instruct. In addition, there is a variety of programming languages designed to fit the problem the programmer is trying to solve.


Download ppt "Copyright © Prentice Hall 20001 Programming and Languages Chapter 14 Telling the Computer What to Do."

Similar presentations


Ads by Google