Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education McGraw-Hill Technology Education Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights
Aug 08, 2015
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved.
McGraw-Hill Technology EducationMcGraw-Hill Technology Education Copyright © 2006 by The McGraw-Hill Companies, Inc. All
rights reserved.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved.
McGraw-Hill Technology Education
Chapter 13A
Creating Computer Programs
Creating Computer Programs
13A-3
What Is a Computer Program?
• Computer programs– Also called software– Computer programs are the list of
instructions. Instructions are called code– CPU execute the instructions – Three types of computer programs
• Operating system• Utility• Application
13A-4
Software Is Stored In Many Files
• Executable files– Contain the instructions for the CPU– Have extensions of .exe
• Many other extensions are commonly found
.dll extension
.ini extension
.hlp extension
13A-5
Hardware/Software Interaction
• Program execution– Software executes at the CPU level– Code to play a sound
• Code generates an interrupt• CPU tells the sound card to play• Sound card plays the file
– Programmer creates the code
13A-6
Hardware/Software Interaction
• Code– Statements written in a programming
language– Writing code can be tedious
• Code must be perfect• Order of steps must be exact
– Writing code is quite exciting• Problems are solved• New ideas are formed
13A-7
Writing Code
13A-8
Hardware/Software Interaction
• Machine code– Recall that computers think in binary– Code is translated into machine code
• CPU executes the machine code
– CPUs have a unique machine code
13A-9
Hardware/Software Interaction
• Compilers and interpreters– Converts source code into binary
• Allows code to execute
– Checks source code for correctness
13A-10
Hardware/Software Interaction
• Compiler– Creates an executable file
• Contents are called object code
– Executable can run on its own– Each language has its own compiler– C++ and Java are compiled languages
13A-11
Hardware/Software Interaction
• Interpreter– Runs program one line at a time– More flexible than compilers– Slower than compilers– Always needed to execute program– Visual Basic and Perl are interpreted
13A-12
Planning a Computer Program
• Plans– The steps to solve a problem– Describe the expected results– Programming without a plan is difficult
13A-13
Planning Tools
• Pseudo code– Natural language statements that
resemble code– Describes what must be done– Can be written by non programmers– Programmers develop unique versions
13A-14
How Programs Solve Problems
• Program control flow– Order program statements are executed– Typically executed in order– Constructs can change the flow
• Decision statements• Loops
13A-15
How Programs Solve Problems
• Algorithm– Set of steps– Always leads to a solution– Steps are always the same– Flowcharts can describe algorithms
• Structured tool for drawing algorithms
– Algorithms appear in all programs
13A-16
Hardware/Software Interaction
• Programming languages– Simplifies the writing of code
• English is used to describe the binary
– Original code is called source code– Several hundred languages exist
PROGRAMING LANGUAGES
13A-17
13A-18
Low Level Language
• A low-level language is a programming language is very close to writing actual machine instructions.
• Low-level languages are considered more difficult to use, however, because they require a deeper knowledge of the computer's inner workings.
• Two good examples of low-level languages are assembly and machine code.
13A-19
1. Machine language
• Programming language that can be directly understood and obeyed by a machine (computer) without conversion.
• It is different for each type of CPU• it is the native binary language (comprised
of only characters: 0 and 1) of the computer and is difficult to be read and understood by humans
• Hardware dependent: Could be performed by only one type of computer with a particular CPU.
13A-20
2. Assembly Language
• An assembly language is a low-level programming language for microprocessors and other programmable devices.
• Assembly language implements a symbolic representation of the machine code needed to program a given CPU architecture.
• It is not just a single language, but rather a group of languages.
• Examples: x86
13A-21
Higher level Language• High-level language is any programming language
that enables development of a program in much simpler programming context and is generally independent of the computer's hardware architecture.
• High-level language has a higher level of abstraction from the computer, and focuses more on the programming logic rather than the underlying hardware components such as memory addressing and register utilization.
• C/C++ and Java are popular examples of high-level languages.
13A-22
Procedural Languages
• Procedural programming language is a list or set of instructions telling a computer what to do step by step and how to perform from the first code to the second code.
• Procedural programming languages include C, Go, Fortran, Pascal, and BASIC.
13A-23
Non-Procedural Languages
– A computer language that does not require writing traditional programming logic.
– Also known as a "declarative language," users concentrate on defining the input and output rather than the program steps required in a procedural programming language
– Many are associated with specific application packages.
• Query Languages: • Report Writers: • Application Generators: 13A-24
Object-oriented programming (OOP)
• It is a programming language model organized around objects rather than "actions" and data.
• Historically, a program has been viewed as a logical procedure that takes input data, processes it, and produces output data.
• Examples: C++/JAVA, Smalltalk
13A-25