Sem2 1718-Bitg1233-Lecture 1 - Intro To Computers and
Sem2 1718-Bitg1233-Lecture 1 - Intro To Computers and
Sem2 1718-Bitg1233-Lecture 1 - Intro To Computers and
LECTURE 1
LECTURE 1 1
Learning Outcomes
At the end of this lecture, you should be able to:
• tell the purpose of computer programs.
• describe the hardware and software components of a
computer system.
• tell about the language of a computer.
• describe the evolution of programming languages.
• list the high-level programming languages.
LECTURE 1 2
Learning Outcomes (cont.)
At the end of this lecture, you should be able to:
• tell about the history of C++ language.
• recognize a C++ program.
• explain the different types of program errors.
• explain how a C++ program is processed and tested.
• explain what compiler, linker and loader are and what
they do.
LECTURE 1 3
Why Program?
• Computer – programmable machine designed to follow
instructions.
• Program – a set of instructions for a computer to follow.
– expressed in a language that the computer can
understand.
• Programmer – person who writes instructions (program)
to make computer perform a task.
LECTURE 1 4
LECTURE 1 5
Computer Components
• Computer is an electronic device, with two
major components.
Computer
Hardware Software
LECTURE 1 6
Computer Hardware
•Hardware refers to the physical parts of the computer
that have mass (they can be touched).
•Hardware for a typical computer system includes the
following FIVE main categories :
1. Main Memory / Primary Storage / Internal Memory
2. Central Processing Unit (CPU)
3. Secondary Storage / Auxiliary Storage / External
Memory
4. Input Devices
5. Output Devices
LECTURE 1 7
Categories of Computer Hardware
LECTURE 1 8
Main Memory
• Main memory stores the instructions and data of the programs
that are running on the computer.
• Main memory’s content can change during program execution.
• It is volatile, which means the main memory’s content is erased
when program terminates or computer is turned off.
• It is also called Random Access Memory (RAM)
• Main memory consists of long list of memory locations.
−Each memory location is called a byte, which has eight bits
(binary digits) that contains zeros and ones.
−Binary Digit or Bit : A digit that can only be zero or one.
LECTURE 1 9
LECTURE 1 10
Main Memory
LECTURE 1 12
Central Processing Unit (CPU)
• Also known as Processor; ”Brain” of the
computer.
• Comprised of:
– Control Unit (CU)
• Retrieves, decodes and executes program
instructions from RAM
• 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
LECTURE 1 13
CPU Organization
LECTURE 1 14
Secondary Storage
• Secondary memory stores instructions and data
between sessions
• Non-volatile: data is preserved when program is
not running, or computer is turned off.
• Comes in a variety of media:
– magnetic: floppy disk drive (FDD), hard disk drive
(HDD), magnetic tape drive
– optical: Compact Disc (CD), Digital Video Disc (DVD)
– flash memory : USB Flash drive
LECTURE 1 15
Input Devices
• Devices that are sources to get input.
• Input is the information sent to the computer.
• Input consists of:
– A program
– Some data
• Many devices can provide INPUT:
– Keyboard, mouse, scanner, digital camera,
microphone, barcode reader, joystick
– HDD, FDD, flash drive, magnetic tape, CD-ROM
LECTURE 1 16
Output Devices
• Devices that send output.
• Output is information from the computer to
the outside world.
• Many devices can be used for OUTPUT:
– Computer monitor, printer, projector, speaker,
headphone, plotter
– HDD, FDD, flash drive, magnetic tape, CD-RW,
DVD-RW
LECTURE 1 17
Computer Software
• Software: refers to program that resides and
executes electronically on the hardware.
• Software is divided into 2 categories:
Software
LECTURE 1 18
System Software
• Normally supplied by the manufacturer of the computer.
• Software that manages computer hardware resources,
and the programs that run on them.
• Basic types of system software:
− BIOS, operating systems, utility programs, software
development tools.
• The operating system is the most important type of
system software. Without it, a user cannot run an
application program on their computer, unless the
application program is self booting.
LECTURE 1 19
Operating System
• The operating system:
− Is a program
− Allows us to communicate with the computer
− Allocates the computer’s resources
− Responds to user requests to run other programs
LECTURE 1 20
Application Software
• Programs that provide services (problem solution)
to the user.
• Designed to perform a specific task (e.g. : course
registration system, banking system) OR a general-
purpose task (e.g. : word processing, games).
• May be acquired by purchasing off-the-shelf or by
designing for own purpose (custom made).
• Off-the-shelf software : Prewritten and ready to
use. For general-purpose task.
• Custom made software: Written by in-house,
consulting firm or software
LECTURE 1
house. For specific task. 21
Where are the application
and system software?
LECTURE 1 22
Programs and
Programming Languages
• A computer program is a set of
written instructions given to a
computer for it to follow. To write a
program needs a programming
language.
• Types of programming languages:
– High-level: closer to human
language
– Low-level: used for
communication with computer
hardware directly. Often written
in binary machine code (0’s/1’s)
directly. LECTURE 1 23
The Language of a Computer
• Machine Language is the language of a
computer.
• Machine Language consists of binary digits
(bits); sequences of 0s and 1s. 0 (signal off) , 1
(signal on)
• Example :
1011010000000101
LECTURE 1 24
History Of Computer Languages
LECTURE 1 25
History Of Computer Languages
(cont.)
1. Machine Language
• Computer only understand this language.
• Series of 1’s and 0’s (binary numbers), such as
1011010000000101
• Difficult to write.
• Low level language
LECTURE 1 26
History Of Computer Languages
(cont.)
• Early computers were programmed in machine
language
• Using machine language, to calculate wages = rates x
hours can be written as:
100100 010001 To load a Value
100110 010010 To multiply it with
another value
100010 010011 To store the result
LECTURE 1 27
History Of Computer Languages
(cont.)
2. Symbolic/Assembly Language
• Unique to particular computer.
• Use mnemonics symbols. E.g. “MULT” –Multiply
• Easier to understand.
LECTURE 1 28
History Of Computer Languages
(cont.)
• Using assembly language instructions,
wages = rates x hours
can be written as:
LOAD rate
MULT hours
STOR wages
• Must be translated to machine language (zeros and
ones) for the CPU to execute a program written in
assembly language.
LECTURE 1 29
History Of Computer Languages
(cont.)
3. High-Level Language
• Are designed to be easy to read and write.
• Programmers use this language to write programs.
• Compiler: is use to translate a program written in a high-
level language to machine language
• Portable to many different computers.
• E.g. COBOL , FORTRAN , Visual Basic, Pascal, C, C++, C#,
Java, Lisp, Ada
• The equation wages = rates x hours can be written in C++
as:
wages = rate * hours;
LECTURE 1 30
Some Well-Known High-Level
Programming Languages
LECTURE 1 31
History Of Computer Languages
(cont.)
4. Natural Language
• Like our natural language (such as English,
French, or Chinese)
• Its use is still quite limited.
LECTURE 1 32
C++ History
• C++ evolved from C
• C++ designed by Bjarne Stroustrup at Bell
Laboratories in early 1980s
• Overcame several shortcomings of C
• Incorporated object oriented programming
• C remains a subset of C++
• C++ programs were not always portable from one
compiler to another
• In mid-1998, ANSI/ISO C++ language standards were
approved
LECTURE 1 33
A Sample of C++ Program
• A simple C++ program begins this way:
#include <iostream>
using namespace std;
int main()
{
• And ends this way:
return 0;
}
LECTURE 1 34
Example of a C++ Program
#include <iostream>
using namespace std;
int main()
{
cout << "My first C++ program." << endl;
cout << "The sum of 2 and 3 = " << 5 << endl;
cout << "7 + 8 = " << 7 + 8 << endl;
return 0;
}
LECTURE 1 35
Program Development
• A computer understands a program only if the
program is coded in its machine language.
• Programmer have to write the program and turn it
into an executable code (machine language).
• Programmer needs to understand the problem ->
break into actions (by writing program)-> execute
by the computer (to see the output).
• In any program development, the output will only
be available if the program does not contain any
errors. LECTURE 1 36
Types of Program Errors
• Syntax errors
– Violation of the grammar rules of the language
– Discovered by the compiler
• Error messages may not always show correct location
of errors
• Run-time errors
– Error conditions detected by the computer at run-time.
• Logic errors
– Errors in the program’s algorithm (logic)
– Most difficult to diagnose
– Computer does not recognize this error
– Detected by the programmer, by checking output of the
program.
LECTURE 1 37
Processing a C++ Program :
From a High-level Program to an Executable Code
Involves these processes:
a) Editing : To create or edit file containing the program with a text editor.
(Program is also called 1 source code)
b) Compiling : The process involves the compiler. The compiler comprises of
two separate programs : preprocessor and translator. Firstly, preprocessor
is run to convert source file directives (instructions that begin with #) to
source code (program) statements. Secondly, the translator checks that
the program obeys the syntax. If all the syntax are being obeyed, the
translator convert the source code into machine language (2object code).
The two steps, are often performed by command COMPILE. Syntax errors
detected will prevent execution of the following process.
c) Linking : Run linker to connect system library functions code to the object
code, producing an 3executable code. Performed by command BUILD.
LECTURE 1 38
From a High-level Program to an Executable Code
LECTURE 1 39
Program Development (cont.)
• Then, after that to produce the output (result of the
program), there are another 2 processes:
d) Loading :
– Loader loads the executable code/program into the
main memory (RAM)
e) Executing:
– The last step is to execute (run) the program to see
the output of the program.
• These 2 processes are often performed by a single
command DEBUG.
LECTURE 1 40
Processing a C++ Program
LECTURE 1 41
Integrated Development
Environments (IDEs)
LECTURE 1 42
Using Visual C++ IDEs :
a) Editing Process
Text
editor
area
LECTURE 1 43
Using Visual C++ IDEs :
b) Compiling Process
Compiling
Status
Message
LECTURE 1 44
Using Visual C++ IDEs :
c) Linking Process
Linking
Status
Message
LECTURE 1 45
Using Visual C++ IDEs :
d) Loading & Executing Processes
Execution Result
(Program’s output)
LECTURE 1 46
Can you…
– List the five main components of a computer?
-the end-
LECTURE 1 47