introduction to programming · chapter 1: introduction to programming ... programming language...
TRANSCRIPT
![Page 1: INTRODUCTION TO PROGRAMMING · CHAPTER 1: INTRODUCTION TO PROGRAMMING ... PROGRAMMING LANGUAGE Johor High Level Language: It enables programmers to program using English-like syntax](https://reader035.vdocument.in/reader035/viewer/2022062303/5fc5353c0b76f045dd1f2323/html5/thumbnails/1.jpg)
Prepared for:
CHAPTER 1:INTRODUCTION TO
PROGRAMMING
CSC 128 – Fundamentals of Computer Problem
Solving
![Page 2: INTRODUCTION TO PROGRAMMING · CHAPTER 1: INTRODUCTION TO PROGRAMMING ... PROGRAMMING LANGUAGE Johor High Level Language: It enables programmers to program using English-like syntax](https://reader035.vdocument.in/reader035/viewer/2022062303/5fc5353c0b76f045dd1f2323/html5/thumbnails/2.jpg)
© Najwa Abd Ghafar – UiTM
Johor
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
![Page 3: INTRODUCTION TO PROGRAMMING · CHAPTER 1: INTRODUCTION TO PROGRAMMING ... PROGRAMMING LANGUAGE Johor High Level Language: It enables programmers to program using English-like syntax](https://reader035.vdocument.in/reader035/viewer/2022062303/5fc5353c0b76f045dd1f2323/html5/thumbnails/3.jpg)
© Najwa Abd Ghafar – UiTM
Johor
Do you think
computers are
dumb or intelligent?
![Page 4: INTRODUCTION TO PROGRAMMING · CHAPTER 1: INTRODUCTION TO PROGRAMMING ... PROGRAMMING LANGUAGE Johor High Level Language: It enables programmers to program using English-like syntax](https://reader035.vdocument.in/reader035/viewer/2022062303/5fc5353c0b76f045dd1f2323/html5/thumbnails/4.jpg)
© Najwa Abd Ghafar – UiTM
Johor
Computer
System
Hardware:
Consists of all the physical
devices
Software (Computer
Program):
Consists of all the instructions
that tell the computer how to
perform tasks
![Page 5: INTRODUCTION TO PROGRAMMING · CHAPTER 1: INTRODUCTION TO PROGRAMMING ... PROGRAMMING LANGUAGE Johor High Level Language: It enables programmers to program using English-like syntax](https://reader035.vdocument.in/reader035/viewer/2022062303/5fc5353c0b76f045dd1f2323/html5/thumbnails/5.jpg)
© Najwa Abd Ghafar – UiTM
Johor
Computer
Program
Is a set of instructions that tells a
computer what to do
Get a glass
Add water
Add a lemon
Add sugar
Taste it
![Page 6: INTRODUCTION TO PROGRAMMING · CHAPTER 1: INTRODUCTION TO PROGRAMMING ... PROGRAMMING LANGUAGE Johor High Level Language: It enables programmers to program using English-like syntax](https://reader035.vdocument.in/reader035/viewer/2022062303/5fc5353c0b76f045dd1f2323/html5/thumbnails/6.jpg)
© Najwa Abd Ghafar – UiTM
Johor
Computer
Program
Programmer
Programming
![Page 7: INTRODUCTION TO PROGRAMMING · CHAPTER 1: INTRODUCTION TO PROGRAMMING ... PROGRAMMING LANGUAGE Johor High Level Language: It enables programmers to program using English-like syntax](https://reader035.vdocument.in/reader035/viewer/2022062303/5fc5353c0b76f045dd1f2323/html5/thumbnails/7.jpg)
© Najwa Abd Ghafar – UiTM
Johor
COMPUTER
What is a Computer?
Is an electronic machine that will:
1. Receive data (input)
2. Store and manipulate those data
(process)
3. Produce useful information
(output)
![Page 8: INTRODUCTION TO PROGRAMMING · CHAPTER 1: INTRODUCTION TO PROGRAMMING ... PROGRAMMING LANGUAGE Johor High Level Language: It enables programmers to program using English-like syntax](https://reader035.vdocument.in/reader035/viewer/2022062303/5fc5353c0b76f045dd1f2323/html5/thumbnails/8.jpg)
© Najwa Abd Ghafar – UiTM
Johor
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
![Page 9: INTRODUCTION TO PROGRAMMING · CHAPTER 1: INTRODUCTION TO PROGRAMMING ... PROGRAMMING LANGUAGE Johor High Level Language: It enables programmers to program using English-like syntax](https://reader035.vdocument.in/reader035/viewer/2022062303/5fc5353c0b76f045dd1f2323/html5/thumbnails/9.jpg)
© Najwa Abd Ghafar – UiTM
Johor
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
![Page 10: INTRODUCTION TO PROGRAMMING · CHAPTER 1: INTRODUCTION TO PROGRAMMING ... PROGRAMMING LANGUAGE Johor High Level Language: It enables programmers to program using English-like syntax](https://reader035.vdocument.in/reader035/viewer/2022062303/5fc5353c0b76f045dd1f2323/html5/thumbnails/10.jpg)
© Najwa Abd Ghafar – UiTM
Johor
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
![Page 11: INTRODUCTION TO PROGRAMMING · CHAPTER 1: INTRODUCTION TO PROGRAMMING ... PROGRAMMING LANGUAGE Johor High Level Language: It enables programmers to program using English-like syntax](https://reader035.vdocument.in/reader035/viewer/2022062303/5fc5353c0b76f045dd1f2323/html5/thumbnails/11.jpg)
© Najwa Abd Ghafar – UiTM
JohorCOMPUTER SYSTEM
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.)
![Page 12: INTRODUCTION TO PROGRAMMING · CHAPTER 1: INTRODUCTION TO PROGRAMMING ... PROGRAMMING LANGUAGE Johor High Level Language: It enables programmers to program using English-like syntax](https://reader035.vdocument.in/reader035/viewer/2022062303/5fc5353c0b76f045dd1f2323/html5/thumbnails/12.jpg)
© Najwa Abd Ghafar – UiTM
Johor
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
![Page 13: INTRODUCTION TO PROGRAMMING · CHAPTER 1: INTRODUCTION TO PROGRAMMING ... PROGRAMMING LANGUAGE Johor High Level Language: It enables programmers to program using English-like syntax](https://reader035.vdocument.in/reader035/viewer/2022062303/5fc5353c0b76f045dd1f2323/html5/thumbnails/13.jpg)
© Najwa Abd Ghafar – UiTM
Johor
COMPUTER SYSTEM
Secondary Storage:
Is the device that stores information permanently
For example:
Hard disks
Floppy disks
CD-ROMs
Thumb Drive
![Page 14: INTRODUCTION TO PROGRAMMING · CHAPTER 1: INTRODUCTION TO PROGRAMMING ... PROGRAMMING LANGUAGE Johor High Level Language: It enables programmers to program using English-like syntax](https://reader035.vdocument.in/reader035/viewer/2022062303/5fc5353c0b76f045dd1f2323/html5/thumbnails/14.jpg)
© Najwa Abd Ghafar – UiTM
Johor
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
![Page 15: INTRODUCTION TO PROGRAMMING · CHAPTER 1: INTRODUCTION TO PROGRAMMING ... PROGRAMMING LANGUAGE Johor High Level Language: It enables programmers to program using English-like syntax](https://reader035.vdocument.in/reader035/viewer/2022062303/5fc5353c0b76f045dd1f2323/html5/thumbnails/15.jpg)
© Najwa Abd Ghafar – UiTM
Johor
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
![Page 16: INTRODUCTION TO PROGRAMMING · CHAPTER 1: INTRODUCTION TO PROGRAMMING ... PROGRAMMING LANGUAGE Johor High Level Language: It enables programmers to program using English-like syntax](https://reader035.vdocument.in/reader035/viewer/2022062303/5fc5353c0b76f045dd1f2323/html5/thumbnails/16.jpg)
© Najwa Abd Ghafar – UiTM
JohorPROGRAMMING LANGUAGE
How do we talk to a Computer?
Computers only understand Machine
Language
Machine 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
![Page 17: INTRODUCTION TO PROGRAMMING · CHAPTER 1: INTRODUCTION TO PROGRAMMING ... PROGRAMMING LANGUAGE Johor High Level Language: It enables programmers to program using English-like syntax](https://reader035.vdocument.in/reader035/viewer/2022062303/5fc5353c0b76f045dd1f2323/html5/thumbnails/17.jpg)
© Najwa Abd Ghafar – UiTM
JohorPROGRAMMING LANGUAGE
Assembly 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
![Page 18: INTRODUCTION TO PROGRAMMING · CHAPTER 1: INTRODUCTION TO PROGRAMMING ... PROGRAMMING LANGUAGE Johor High Level Language: It enables programmers to program using English-like syntax](https://reader035.vdocument.in/reader035/viewer/2022062303/5fc5353c0b76f045dd1f2323/html5/thumbnails/18.jpg)
© Najwa Abd Ghafar – UiTM
JohorPROGRAMMING LANGUAGE
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
![Page 19: INTRODUCTION TO PROGRAMMING · CHAPTER 1: INTRODUCTION TO PROGRAMMING ... PROGRAMMING LANGUAGE Johor High Level Language: It enables programmers to program using English-like syntax](https://reader035.vdocument.in/reader035/viewer/2022062303/5fc5353c0b76f045dd1f2323/html5/thumbnails/19.jpg)
© Najwa Abd Ghafar – UiTM
Johor
THINGS TO KEEP IN MIND