Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (1 vote)
460 views

Intro To Programming PDF

Uploaded by

Hafiz Anuar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
460 views

Intro To Programming PDF

Uploaded by

Hafiz Anuar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

CHAPTER 1:

INTRODUCTION TO
PROGRAMMING

Prepared for:
CSC 402 – Programming 1

© Najwa Abd Ghafar – UiTM Johor


© Rose Hafsah Ab Rauf – UiTM Shah Alam
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab, Rauf - UiTM Shah Alam

OBJECTIVES OF THIS CHAPTER

In this chapter, you will learn about:


 What is a computer
 The components of a computer system
 What is a computer program
 Programming Languages
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab, Rauf - UiTM Shah Alam

Do you think
computers are
dumb or intelligent?
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab, Rauf - UiTM Shah Alam

Hardware:
Consists of all the physical devices

Software (Computer Program):


Consists of all the instructions
that tell the computer how to
perform tasks
Computer
System
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab, Rauf - UiTM Shah Alam

Get a glass

Add water

Add a lemon

Add sugar

Computer Program
Taste it

Is a set of instructions that tells a computer


what to do
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab, Rauf - UiTM Shah Alam

Computer Program Programming

Programmer
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab, Rauf - UiTM Shah Alam

COMPUTER

Is an electronic machine that will:


What is a Computer? 1. Receive data (input)
2. Store and manipulate those data (process)
3. Produce useful information (output)
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab, Rauf - UiTM Shah Alam

COMPUTER SYSTEM

Components of a Computer System:


1. Hardware:
 Input and Output Devices
 Central Processing Unit (CPU)
 Main Memory
 Secondary Storage
2. Software:
 Operating System
 Application Software
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab, Rauf - UiTM Shah Alam

COMPUTER SYSTEM

Input:
 Are data that is entered into the computer using an input device

Input Devices:
 Are used to send or enter data into a computer
 For example:
 Keyboard
 Mouse
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab, Rauf - UiTM Shah Alam

COMPUTER SYSTEM

Processing:
 Are the task of performing operations inside the computer system and this
is carried out by the CPU

Central Processing Unit (CPU):


 Is the “brain” of the computer
 Because it is responsible in handling all the instructions you give your computer
through a computer program
 It performs:
 Arithmetical and logical operations
 Input/output operations
COMPUTER SYSTEM
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab, Rauf - UiTM Shah Alam

Central Processing Unit (CPU):


 Consists of 2 main components:
1. Control Unit (CU):
Is responsible in directing the operations within the processor by:
 Telling the computer's memory, arithmetic/logic unit and input and
output devices how to respond to a program's instructions

2. Arithmetic and Logic Unit (ALU):


Is responsible in performing:
 Arithmetical operations
(E.g.: addition, subtraction,
multiplication and division)
 Logical operations (comparison)
(E.g.: equal to, not equal to, less than,
greater than etc.)
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab, Rauf - UiTM Shah Alam

COMPUTER SYSTEM
Storage:
 Is the process of saving data and instructions inside the computer system
 There are 2 types of storage:
1. Main Memory / Primary Storage
2. Secondary Storage

Main Memory:
 Also known as Random Access Memory (RAM)
 Will hold data and program instructions for data processing
 Will hold processed information before it is displayed as output
 Is a temporary storage because its content will be lost once the computer is
turned off
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab, Rauf - UiTM Shah Alam

COMPUTER SYSTEM

Secondary Storage:
 Is the device that stores information permanently
 For example:
 Hard disks
 Floppy disks
 CD-ROMs
 Thumb Drive
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab, Rauf - UiTM Shah Alam

COMPUTER SYSTEM

Output:
 Are any information or results produced by the computer system and are
displayed using output devices

Output Devices:
 Are used to display data which has been processed or has been stored on
the computer
 For example:
 Monitor
 Printer
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab, Rauf - UiTM Shah Alam

COMPUTER SYSTEM
Software:
 Is a computer program, which will direct the computer to do the tasks
you want it to do and to produce the results you want

 There are 2 types of software, which are:


1. Operating System
 Is a program that will control and manage
all the other programs inside the computer
 For example:
Windows OS, Mac OS, Linux OS
2. Application Software
 Is a program that will provide
services to the user
 For example:
Word processing, games, web browsers
PROGRAMMING LANGUAGE
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab, Rauf - UiTM Shah Alam

How do we talk to a Computer?


 Computers only understand Machine Language

Machine Language (Low Level Language):


 Data and instructions are represented in a series of 0’s and 1’s (binary code)

For example: To code wages = rates x hours in Machine Language will be:

100100 0000 010001


100110 0000 010010
100010 0000 010011
PROGRAMMING LANGUAGE
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab, Rauf - UiTM Shah Alam

Assembly Language (Low Level Language):


 Instructions are represented using an easy-to-remember form called mnemonic
and is slightly easier to use than Machine Language (more readable)

For example:

 However, an assembler is used to translates a program written in assembly


language into an equivalent program in machine language

For example: To code wages = rates x hours in Assembly Language will be:

LOAD R1, rate


MULT R1, hour
STOR R1, wages
PROGRAMMING LANGUAGE
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab, Rauf - UiTM Shah Alam

High Level Language:


 It enables programmers to program using English-like syntax and is a lot easier
to read, write and maintained

For example: To code wages = rates x hours in High Level Language will be:

wages = rates * hours;

 However, a compiler will be used to translates a program written in high


level language language into an equivalent program in machine language
 Example of High Level Language:
C++, Java, COBOL, Fortran
PROGRAMMING LANGUAGE
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab, Rauf - UiTM Shah Alam

Low Level Language:


 Is a programming language that is closely related to the computer’s hardware:
 Programmers are required to know how to manage hardware components
 This includes Machine Language and Assembly Language

High Level Language:


 Is a programming language that is an “abstraction” (far away) from machine code
instructions:
 Doesn’t require knowledge about hardware
 Enables programmers to just focus on the problem being solved
Interpreter and Compiler
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab, Rauf - UiTM Shah Alam

A program written in high level language is called


a source code
A computer only understands a program written in
binary (0’s and 1’s)
We need to convert the source code into machine
code which can be done by compilers and
interpreters.
Interpreter and Compiler
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab, Rauf - UiTM Shah Alam

Interpreter Compiler
Translates program one statement at Scans the entire program and
a time. translates it as a whole into machine
code.
It takes less amount of time to It takes large amount of time to
analyze the source code but the analyze the source code but the
overall execution time is slower. overall execution time is
comparatively faster.
No intermediate object code is Generates intermediate object code
generated, hence are memory which further requires linking, hence
efficient. requires more memory.

Continues translating the program It generates the error message only


until the first error is met, in which after scanning the whole program.
case it stops. Hence debugging is Hence debugging is comparatively
easy. hard.
Interpreted code run slower Compiled code run faster

Programming language like Python, Programming language like C, C++


Ruby use interpreters. use compilers.
Interpreter and Compiler
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab, Rauf - UiTM Shah Alam
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab, Rauf - UiTM Shah Alam

THINGS TO KEEP IN MIND

You might also like