Vous êtes sur la page 1sur 34

Lecture #1: Introduction to PSP Problem solving Programming

Quaid-i-Azam University Islamabad


Problem Solving and Programming
Zafar Saeed
zafarsaeed@cs.qau.edu.pk
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
Course Outline
Sessional# 1
Sessional# 2
Terminal
If time permits
Course Evaluation
Sessional (Each): 12.50%
Quizzes 5%
Assignments 10%
Project 10%
Final 50%
Topic Sessions
Introduction to Problem Solving and Programming 1
Problem Solving Concept for the Computer 2--4
Constants and Variables -- Rules and Data types -- Operators -- Expression and Equality
Logic Structures 5--7
Programming Structures -- Modules and Functions -- Cohesion and Coupling
Local and Global Variables -- Pointers/Parameters/Return Values
Sequential Logic Structures 8--9
Flow Charts -- Sequential Logic
Decision Logic Structures 10--11
Decision Logic Structures [IF, ELSE IF, ELSE] -- Case Logic Structure
Loop Logic Structures 12--14
Counter Loop -- Conditional Loop -- Repeat Until -- Array
Introduction to Programming: Syntactic Constructs
Syntactic and Program Conventions -- Decision Logic and Loop logic Structures 15--18
Function, Parameters and Overloading 19--21
Project Assignment
User Define Data type/ Pointers/ Array and Link List 22--24
File Processing 25--26
Sequential Access
Program Testing and Debugging 27--28
Documentation 29--30
Some additional topics
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
Books
Problem Solving and Programming Concepts 7th Ed.
By Maureen Sprankle

How to solve it by Computer.
By R. G. Dromey

Algorithm Development and Program Design using C.
By Gary J. Bronson
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
Introduction to Computer
System
Lecture# 1
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
Lecture Objectives
Introduction to Computer Systems
Components of a Computer System
Input/Output Devices
Motherboard
Processor
Memory
Main memory
Secondary memory
Bits and Bytes
Software
Types of software
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
Introduction to Computer Systems
A data processing machine capable of
performing computations and making
logical decisions very fast
A computer is a complex system consisting
of both hardware and software
components.


Computer System
Hardware Software
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
A computer system consists of both
hardware and software components.
The hardware components of a computer
system are the electronic and mechanical
parts.
The software components of a computer
system are the intangible parts: the data
and the computer programs.
Components of a Computer System
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
The major hardware components of a
computer system are:
Processor
Main memory
Secondary memory
Input devices
Output devices
The processor, main memory, secondary
memory, and power supply are inside the
systems unit/Box.
Components of a Computer System
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
Components of a Computer System
Peripheral Devices
Keyboard
Mouse
Monitor .. etc
Input Devices
Mouse
Keyboard .. etc
Output Devices
Monitor
Printer .. etc

Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
Input/Output Devices
Input and output devices allow the computer system to
interact with the outside world by moving data into and out
of the system.
An input device is used to bring data into the system.
Some input devices are:
Keyboard
Mouse
Microphone
Bar code reader
Light pen
An output device is used to send data out of the system.
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
Some output devices are:
Monitor, Printer, Speaker etc
Input/output devices are usually called I/O devices.
They are directly connected to an electronic module
inside the systems unit called a device controller.
For example, the speakers of a multimedia
computer system are directly connected to a device
controller called an audio card (such as a
SoundBlaster), which in turn is connected to the rest
of the system.
Input/Output Devices
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
The terms "input" and "output" say if data
flow into or out of the systems unit.
The picture shows the major hardware
components of a computer system. The
arrows show the direction of data flow.
Components of a Computer System
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
Components of a Computer System
Main board, often called motherboard.
All computer Components are attached directly
or indirectly with the motherboard.
The power supply supplies power for most
of the components.
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
The bus is a group of wires on the main
circuit board of the computer.
It is a pathway for data flowing between
components.
Most devices are connected to the bus
through a controller which coordinates the
activities of the device and the bus.
The processor is an electronic device about a
one inch square.
Inside the square is an even smaller square
of silicon containing millions of tiny electrical
parts.
Components of a Computer System
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
A processor may contain 100 million
transistors.
The processor is the "brain" of the computer
system.
It does the fundamental computing within the
system, and directly or indirectly controls all
the other components.
The processor is sometimes called the
Central Processing Unit or CPU.
Processor
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
A CPU contains arithmetic and logic unit
(ALU), control unit (CU) and registers.
ALU performs calculations such as addition,
subtraction, multiplication and division and
logical operations such as comparing two
numbers.
CU controls the order in which program
instructions are executed.
Registers are high speed memory cells used
to store temporary results produced by ALU
as well as certain control information
Processor (cont..)
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
The processor is the brain of the computer.
All fundamental computing takes place in the
processor.
Unlike a human brain, which combines
memory with processing power, a computer
processor has very little memory.
It must rely on other components to hold
data and programs and to save results.
The memory in a computer system is of two
fundamental types:
Main memory
Secondary memory
Memory
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
Closely connected to the processor.
contents are quickly and easily changed.
holds the programs and data that the
processor is actively working with.
interacts with the processor millions of times
per second.
Main memory is where programs and data
are kept when the processor is actively using
them.

Main Memory
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
When programs and data become active,
they are copied from secondary memory into
main memory where the processor can
interact with them.
A copy remains in secondary memory.
Main memory is intimately connected to the
processor, so moving instructions from the
program and data into and out of the
processor is very fast.
Main Memory (cont..)
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
Also called RAM (Random Access Memory).
"Random" means that the memory cells can
be accessed in any order.
One megabyte of memory is enough to hold
approximately one million characters of a
word processing document.
Nothing permanent is kept in main
memory.
Main Memory (cont..)
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
Connected to main memory through the bus
and a controller.
The contents are easily changed, but changes
are slow compared to main memory.
Used for long-term storage of programs and
data.
Before its data and programs can be used,
they must be copied into main memory.
Secondary Memory (cont..)
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
Secondary memory is where programs and data are
kept on a long-term basis.
Common secondary storage devices are the hard
disk and flash drives.
The hard disk has enormous storage capacity
compared to main memory.
The hard disk is usually contained in the systems
unit of a computer.
Data and programs on the hard disk are organized
into files.
A file is a named section of the disk.
Secondary Memory (cont..)
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
The reason for having two types of storage is this
contrast:
Primary memory Secondary memory
1. Fast Slow
2. Expensive Cheap
3. Low capacity Large capacity
4. Works directly with Not connected directly
the processor to the processor
Secondary Memory (cont..)
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
In both main and secondary memory, information is stored
as patterns of bits.
A bit is a single on/off value. Only these two values are
possible. The two values may go by different names, such
as true/false, or 1/0. There are many ways in which a bit
can be implemented.
One bit of information is so little that usually computer
memory is organized into groups of eight bits.
Each eight bit group is called a byte.
When more than eight bits are required for some data, a
whole number of bytes are used. One byte is about enough
memory to hold a single character.
Bits and Bytes
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
Bits and Bytes (cont..)
A is a character and represented in 8 bits as
01000001 in computer
Similarly B represented as 01000010
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
Often very much more than eight bits are required
for data, and thousands, millions, or even billions of
bytes are needed. These amounts have names, as
seen in the table.

Name Number of Bytes power of 2
Byte 1 2
0
kilobyte 1024

2
10
megabyte 1,048,576 2
20

gigabyte 1,073,741,824 2
30

terabyte 1,099,511,627,776 2
40

Bits and Bytes (cont..)
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
Computer software consists of both programs and data.

Programs are lists of instructions for the processor.

Data can be any information that a program needs:
character data, numerical data, image data, audio data, and
countless other types.

The distinction between programs and data is not as clear-
cut as you might think, however.
Software
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
Fundamental Idea: Both programs and data are saved in
computer memory in the same way.

The electronics of computer memory (both main memory
and secondary memory) make no distinction between
programs and data.
Software (cont..)
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
There are two categories of programs.
Application software (usually called just
"applications") are programs that people use to get
their work done.

Systems software keep all the hardware and
software running together smoothly.

Computers exist because people want to run these
programs.
Types of Software
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
Application Programs Systems Programs
Word processors Operating system
Game programs Utilities
Spreadsheets Programming languages
Data base systems Data Recovery
Graphics programs Data backup
Web browsers
The most important systems program is the operating
system.
The operating system is always present when the computer
is running.
It coordinates the operation of all the hardware and software
components of the computer system.
Types of Software (cont..)
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
Types of Software (cont..)
Application Software
System Software
System Hardware
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
The operating system is responsible for starting
application programs running and finding the
resources that they need.
For example, when a command is given for printing
a document, OS allocate the printer to the
application.
Modern operating systems usually come with a
graphical user interface (GUI) that enables users to
easily interact with programs by using windows,
buttons, menus, icons, the mouse, and the
keyboard.
Types of Software (cont..)
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
When a computer is first started, the hardware will
automatically load the operating system and start it
running.

This process is called booting.

Once the operating system is running, it is used to
start up application programs.
Starting a Program
Lecture #1: Introduction to PSP Problem solving Programming
Quaid-i-Azam University Islamabad
Here is a (simplified) list of what happens when the user
(you) starts up an application.
1. The user asks to run an application. This could be done by clicking
on an icon, making a menu choice, or other means.
2. The OS determines the name of the application.
3. The OS finds the section of the hard disk where the application
program and where its data are stored.
4. The OS finds an unused section of main memory that is large
enough for the application.
5. The OS makes a copy of the application and its data in that section
of main memory.
6. The OS sets up resources for the application.
7. Finally, the OS starts the application running.
Starting a Program (cont..)

Vous aimerez peut-être aussi