Wednesday, April 23, 2008

Chapter 1: An Overview of Computers and Logic







http://docs.google.com/Presentation?id=dhr4fww_12hnmn59g2



Note: This was a lecture in a Graduate School.

Programming Logic and Design, Third Edition Comprehensive


Objectives

After studying Chapter 1, you should be able to:

* Understand computer components and operations

* Describe the steps involved in the programming process

* Describe the data hierarchy

* Understand how to use flowchart symbols and pseudocode statements

* Use and name variables

* Use a sentinel, or dummy value, to end a program

* Use a connector symbol

* Assign values to variables

* Recognize the proper format of assignment statements

* Describe data types

* Understand the evolution of programming techniques

Understanding Computer Components and Operations

* Hardware: equipment, or devices, associated with a computer

* For a computer to be useful, it needs more than equipment; a computer needs to be given instructions

* The instructions that tell the computer what to do are called software, or programs, and are written by programmers

* Hardware devices that perform input include keyboards and mice

* Through input devices,
> data, or facts, enter the computer system

* Processing data items may involve
> organizing them,
> checking them for accuracy, or
> performing mathematical operations on them

* The hardware that performs these sorts of tasks is the central processing unit, or CPU

* After data items have been processed, the resulting information is sent to a printer, monitor, or some other output device so people can view, interpret, and use the results

* You write computer instructions in a computer programming language, such as Visual Basic,

* Pascal, COBOL, RPG, C#, C++, Java, or Fortran

* Every language has rules governing its word usage and punctuation

* Programming rules are called the language’s syntax

* Each programming language uses a piece of software to translate the specific programming language into the computer’s on-off circuitry, or machine language

* The language translation software, known as a compiler or interpreter, tells you if you have used a programming language incorrectly

* For a program to work properly, you must give the computer exact instructions in a specific sequence

* By doing this, you are developing the logic of the computer program

* Once instructions have been inputted to the computer and translated into machine language, a program can be run, or executed

* Besides input, processing, and output, all computer systems need and have:
> Internal storage, commonly called memory, main memory, or primary memory. Though needed to run programs, internal memory is volatile—that is, its contents are lost every time the computer loses power
> External storage, or permanent storage outside the main memory of the machine, is held on a device such as a floppy disk, hard disk, or magnetic tape

Understanding the Programming Process

* The programmer’s job can be broken down into six programming steps:
> Understand the problem
> Plan the logic
> Code the program
> Translate the program into machine language
> Test the program
> Put the program into production

Understand The Problem

* Really understanding the problem may be one of the most difficult aspects of programming
> The description of what the user needs may be vague
> The user may not even really know what he or she wants
> Users who think they know what they want frequently change their minds after seeing sample output

* A good programmer is often part counselor, part detective

Plan the Logic

* Programmer plans the steps to the program, deciding what steps to include and how to order them

* The two most common tools are flowcharts and pseudocode

* Both tools involve writing the steps of the program in English

Code the Problem

* Some very experienced programmers can successfully combine the logic planning and the actual instruction writing, or coding of the program, in one step

* A good term paper needs planning before writing, and so do most programs

Translate the Program into Machine Language

* Languages such as Java or Visual Basic translate the programmer’s English-like high-level programming language into the low-level machine language that the computer understands

* If you write a programming language statement incorrectly (for example, by misspelling a word, using a word that doesn’t exist in the language, or using “illegal” grammar), the translator program doesn’t know what to do and issues an error message identifying a syntax error

* All syntax errors are caught by the compiler or interpreter

* When writing a program, a programmer might need to recompile the code several times

* An executable program is created only when the code is free of syntax errors

* When you run an executable program, it might also typically require input data

Creating an Executable Program

[insert picture here -page 16]

No comments: