Download Computer Program

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
What is a Computer?
An, electrical machine, that can be programmed to
accept data (input), process it into useful information
(output) and store it away for later use.
What is a Computer?
An, electrical machine, that can be programmed to
accept data (input), process it into useful information
(output) and store it away for later use.
Data
Process
Information
What is Computer Programming?
• Telling the computer what to do.
• Giving the computer instructions.
• Modeling the real world.
Computer Program
A set of step-by-step instructions that tells a computer
what to do and produces a desired result.
Computer Programmer
A person who writes (generates) a computer program.
Computer
Consists of the following components:
• Hardware
• Software
Hardware
Consists of the following components:
•
•
•
•
•
Input devices
Gives the computer it’s
five senses.
Output devices
Central Processing Unit (CPU)
Main memory
Secondary Storage
Anything you can touch! (Physical Components)
Hardware Definitions (1/2)
Input Devices (Keyboard, Mouse)
• Where the user enters data and programs into the computer.
Output Devices (Printer and Monitor)
• Where the information and programs will be shown to the
user.
Storage Devices (Floppy and Hard Disk).
• Where programs and data can be stored and retrieved. When
the computer is turned off the information does not go away.
Non-volatile.
Hardware Definitions (2/2)
Memory
• Locations (places) where programmers can store and retrieve
data and instructions temporarily.
•
• When you turn the computer off the information is lost.
Volatile.
CPU:
• Interprets and executes program instructions.
• Communicates with all other hardware components.
• Performs the arithmetic, logical and relational operations
• The “brain” of the computer.
Hardware: Information Flow
Processor
Input Devices
Memory
CPU
Output Devices
Secondary
Storage
Key Concepts
Memory
• Each memory cell has a unique address. Where am I?
• Each memory cell has some contents.
What’s inside?
- No cell is ever empty!!!
Think of a parking lot, post office box, home, etc...
CPU
The CPU can only process data and instructions that are in
MEMORY!!
Software
Consists of the following components:
• Operating System
• System Development Software
• Application Software
Things you can not touch! (Intangible)
Operating Systems
• Allows the application (program) to talk to
the hardware.
• Manages the hardware for the entire
computer system.
• Unix, Windows 95, MS-DOS, OS/2,
MAC-OS, etc.
System Development Software
• Allows the programmer to write and run
(execute instructions) programs.
• Editor, compiler, interpreters, linkers,
loaders, etc.
Application Software
• Software designed for a specific use.
• Excel, Word, Access, Powerpoint, Paint,
Lotus 1-2-3, Netscape, Outlook, etc.
• Any program you write for this class.
A Programmer’s Environment
Hardware
Why do we need Programming Languages?
 Computers don’t speak the same language
as humans.
 Humans speak natural languages(English,
French, Chinese, Russian, etc.).
 Computers speak in a language called
"machine language".
 Therefore some translation must be done.
Machine Language
 Machine language is the only language understood by
a computer.
 Machine language is based on a number system called
the Binary System.
Binary System has just two digits - 0 (zero) and 1(one).
 Machine language programming is very tedious, timeconsuming, error-prone and hard to fix.
 Machine language programs only work on the
computer the program was written for.
High-level Language
 Java is considered a High-level language.
 High-level languages are designed to be less tedious,
less time-consuming, less error-prone and easier to fix.
 High-level language programs can work on different
computers.
 High-level language programs must be translated to
machine language. Compilation or Interpretation
Text Editor
 Software used to enter, change and store your
computer programs.
 Has your basic word-processing functions:
 Search, locate and replace.
 Copy, Move and Paste commands.
 Formatting commands.
 When complete the program is saved and is
called the source file.
Compiling and Running
 The Java compiler, javac, takes your source file and
translates its text into instructions that the Java Virtual
Machine can understand. The instructions contained within
this file are known as “bytecodes”.
The Java launcher, java, uses the Java Virtual Machine
which takes the “bytecodes” and translates them into
machine language, and loads the machine language into
memory and runs (executes) the program.
Programming Errors
Syntax Error
 Violation of C++ grammar rules.
 Errors are detected by the compiler and displayed.
 Program will not be translated.
Run-time Error
 Not detected by the compiler.
 Error occurs after the program begins running.
Logic Error
 Bad instructions.
 Error can only be detected by the programmer.