- A programmable device that can store, retrieve, and process data
- Actual circuits and associated machinery (physical components)
- Keyboard, monitor, disk, tape, floppy drive, camera, microphone
- Another name for a program or programs
- systems software (operating system, editor, compiler) and
applications software
- The step-by-step instructions that tell the computer how to do its work
- These instructions are in a language understood by the computer
- A set of rules, symbols, and special words used to construct a program
- C and C++ are languages understood by the computer
- Problem-Solving Phase
* Analysis and Specification
* Develop an algorithm (a step-by-step procedure for solving the problem)
* Verify the algorithm by following the steps exactly
* Example: drive to the airport
Get on I10 if traffic heavy, Drive to Exit 18 Turn right on River Road Turn left at airport entrance else Drive to exit 23 Turn left on River Road Turn right at airport entrance Search lot for parking space
- Implementation phase
* Translate the algorithm into a program (coding)
* Test the program and correct possible errors (debugging)
- Maintenance phase
* Use the program
* Maintain the program by modifying it to meet new requirements and correct
new errors
<Figure 1-2>
- The comments that make a program easier for others to understand, use, and modify
- Any knowledge that can be communicated
- Information that can be put into a form a computer can use
- Data are represented by 1s and 0s (binary form) in the memory of the
computer
- A single 1 or 0 is called bit
- A group of 8 bits is called byte (2^8=256 combinations)
- Each character (A,a,B,b,*,+,...) is usually represented by a byte inside the
computer
Programming Languages
- A language made up of binary-coded instructions, that is used directly by the
computer
- Different computers might represent the same instruction with different codes
- The machine code for one computer is not the same as for another
- Programs written in machine language are very difficult to read and modify
- Similar to machine language with the difference that instructions are in an
easy-to-remember form
- A program that translates an assembly language program into machine code
(assembler) is needed
Assembly language Machine language ADD 100101 SUB 010011
- Easier to use than assembly or machine languages because they are closer to
English
- C, C++, Pascal, Fortran, Cobol, Ada are all high-level languages
- A program (compiler) translates programs written in a high-level
language (source program) into machine language (object program)
- A benefit of high-level languages is that the allow the programmer to write
machine independent (portable) code
- Programs written in assembly or machine languages are not portable from
one computer to another
<Figure 1-5>
- During compilation, the computer translates the source program to an object
program
- During execution, the object program is loaded into the computer's memory
and the computer executes (runs) each instruction of the object program
<Figure 1-6>
- Sequence: a series of statements that are executed one after another
- Selection: different statements are executed depending on certain
conditions
- Loop: instructions are repeated while certain conditions are met
- subprogram: break a program into smaller units
<Figure 1-7>
Computer Organization
<Figure 1-8>
- Eyes and ears of the computer
- Used to receive informations from the outside world
- Connects to different -peripheral- devices (keyboard, mouse, video
camera etc.)
- Tongue/mouth, hands, and legs of a computer
- Used to communicate information, or to do something
- Monitor screen, printer, robotic arm
- Brain of the computer
- Talks to every other unit via the nervous system (buses or wires)
- Responsible for the behavior of every other unit in the system
- Specialized part of the brain that is good at math and at making very simple
decisions
- Generally referred to as a co-processor
- Specialized part of the brain that controls the actions of the other units so That the instructions (program) are executed in the correct sequence
- Used by the CPU to keep instructions and data during the execution of a
program
- Organized as an ordered sequence of storage cells, each of which can hold
a piece of data
Each memory cell has a distinct address which is used to store and retrieve
information
- CPU picks up an instruction from memory and acts on it
- Also known as RAM or Random Access Memory
<Figure from page 53 and Figure 1-9>
- Long term storage for programs that are not in active use at the time
- Also used to keep data that needs to be stored for long term
- Magnetic tape drives, disk drives, CD-ROM drives, etc.
- Operating system: a collection of programs that control and allocate
resources in a computer system - both in hardware and software
- Editor: an interactive program used to create and modify source programs
or data
Four Kinds of Computers
- Very large (they can fill a room) and very fast
- Used by big companies (insurance companies, airlines companies etc.)
- Many users
- Small computers that can fit on top of a desk
- Usually one user
- Intermediate-sized computers (workstations)
- Less expensive than mainframes and more powerful than personal computers
- Used mostly by research institutions
- One or more users
- Tremendous processing power (Deep Blue vs Kasparov !!!)
- Include many CPUs
- Used mostly for research
History of C++
- Designed by Martin Richards in 1967
- Useful for writing system software like compilers and operating systems
- Developed by Ken Thompson for early versions of UNIX
- Inspired by BCPL
- Developed by Dennis Richie (AT&T Bell Labs) in 1972
- Developed by Bjarne Stroustrup (Bell Labs) in 1985
- It is a superset of C
Problem-Solving Techniques: Some Hints
- A clear statement of the problem
- The necessary input
- The required output
- Do not reinvent the wheel !!!
<Figure 1-12>
- Draw an analogy between the problem you are trying to solve and other
problems
- Do not limit yourself to computer-oriented solutions
- Having a broad experience will make you a good programmer
<Figure 1-13>
- Break up large problems into smaller units that are easier to solve
<Figure 1-15>