You are on page 1of 41

Chapter 1

Introduction to Computer systems,


programming languages and
programming
1
Computer Systems

Program - A set of instructions for a computer to


follow.
Software - The collection of programs used by a
computer.

But what is a computer?


A computer is a system made of two major
components: hardware and software.
2
Hardware
A PC (personal computer) - small computer designed to
be used by one person at a time. Most home computers
are PCs, but PCs are also widely used in business, industry,
and science.
A workstation is essentially a larger and more powerful
PC. You can think of it as an industrial-strength PC.
A mainframe is an even larger computer that typically
requires some support staff and generally is shared by
more than one user.
3
4
Hardware (cont)

A network consists of a number of computers


connected so that they may share resources such as
printers and may share information.
A network might contain a number of workstations
and one or more mainframes, as well as shared
devices such as printers.

5
6
Input Devices

Any device that allows a person to communicate


information to the computer.
Many devices can provide input:
Keyboard, mouse, scanner, digital
camera, microphone
Disk drives, CD drives, and DVD
drives
7
Output Devices

is anything that allows the computer to communicate


information to you.
Many devices can be used for output:
Computer monitor and printer
Disk drives
Writable CD and DVD drives
8
9
Central Processing Unit (CPU)
Comprised of:

Control Unit
Retrieves and decodes program instructions
Coordinates activities of all other parts of computer

Arithmetic & Logic Unit (ALU)


Hardware optimized for high-speed numeric calculation
Hardware designed for true/false, yes/no decisions
10
CPU Organization

11
12
Main Memory
It is volatile. The program that is being executed is kept in
main memory.
Main memory is erased when program terminates or
computer is turned off
Also called Random Access Memory (RAM)
Organized as follows:
bit: smallest piece of memory. Has values 0 (off,
false) or 1 (on, true)
byte: 8 consecutive bits. Bytes have addresses.
13
Main Memory

Addresses Each byte in memory is identified by a


unique number known as an address.

Above figure, the number 149 is stored in the byte with the address 16, and
the number 72 is stored at address 23.
14
Secondary Storage
Non-volatile: data retained when program is not running
or computer is turned off

Comes in a variety of media:


magnetic: floppy disk, hard drive
optical: CD-ROM, DVD
Flash drives, connected to the USB port
15
Software

Software Programs That Run on a Computer

Categories of software:
Operating system: programs that manage the
computer hardware and the programs that run on
them. Examples: Windows, UNIX, Linux

Application software: programs that provide


services to the user. Examples : word processing,
games, programs to solve specific problems
16
17
18
What is a Program?

A program is a set of instructions that the


computer follows to perform a task

19
Computer Languages
To write a program for a computer, we must use a computer
language.

BUT,
What is a Computer Language?
What makes a computer language?
Why do computers have them?
Why are there so many different computer languages?
20
History of Programming Language
Computers are electronic, and they are digital.
No voltage means a zero to the electronic devices (e.g.
computers), and have voltage means a one.

21
Computer Language Evolution 22
Note
The only language understood by computer
hardware is machine language.

23
Machine Language

Machine language instructions are binary numbers,


such as

1011010000000101

Rather than writing programs in machine language,


programmers use programming languages.

24
The Multiplication Program in Machine Language

25
Also called as assembly language

Computer Language Evolution 26


Note
Symbolic language are much easier to program in because they allow a programmer to
substitute names, symbols to represent the various machine language instructions.

27
The Multiplication Program in Symbolic Language

28
Computer Language Evolution 29
Note
High-level languages are codes similar to everyday English and uses mathematical
notations
Example: grossPay = basePay + overTimePay

30
The Multiplication Program in C++

31
Types of Programming Languages
Low-level:
used for communication with computer
hardware directly. Often written in binary
machine code (0s/1s) directly.

High-level: closer to human language

32
Some Well-Known Programming Languages

C++
BASIC Ruby
Java
Visual Basic
COBOL C#
JavaScript
C Python 33
The program which is using the second and third generation languages
for writing will use a compiler to turns it into machine code.

Source Code
Machine
In 2nd / 3rd Compiler
Language
language

34
From a High-level Program to an
Executable File
a) Create file containing the program with a text editor.
b) Run preprocessor to convert source file directives to source
code program statements.
c) Run compiler to convert source program into machine
instructions.
d) Run linker to connect hardware-specific code to machine
instructions, producing an executable file.
Steps bd are often performed by a single command or button
click.
Errors detected at any step will prevent execution of following
steps.
35
Source Code Object Code

Preprocessor Linker

Modified Executable Code


Source Code

Compiler

36
The Programming Process

37
PROBLEM
Analyse the problem

Do Planning to Solve Problem (model)

Algorithm & Flowchart

Write a source code to solve problem

C++ Program

38
Example of C++ Program

39
Summary of Chapter 1:
A computer is a system made of two major components:
hardware and software.

Central Processing Unit (CPU) consists of Control Unit &


Arithmetic & Logic Unit (ALU)

Main Memory is a volatile storage, secondary Storage is a non


volatile storage.

Input devices send data from user to computer , output devices


send data from computer to user.
40
A program is a set of instructions that the computer follows to
perform a task.

3 kinds of programming languages: Machine language,


symbolic/assembly language, high-level language.

An algorithm and flowchart are developed after the analysing


stage.

41

You might also like