Topic 1 - Introduction To Computers and Programming PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 37

CSC402

PROGRAMMING 1
LECTURE: 01 – INTRODUCTION TO COMPUTERS AND PROGRAMMING
2/21

Learning Objectives:
After completing this chapter, you will be able to:
• know a history of computer
• explain types, hardware and software components of a computer
system
• describe about the language of a computer
• explain about the evolution of programming languages
• discover what a compiler, interpreter, assembler is and what it
does
• describe program development life cycle
• differentiate type of programming paradigm
3/21

Brief History of a Computer?


The computer as we know it today had its beginning with a 19th
 Inmathematics
century English 1994, reports
professor name Charles Babbage.
 31% cancelled
53%
 born
The computer was notmore than 2x over
for entertainment budget
or email but out of a
need to solve a serious number-crunching crisis.

Today, we carry more computing power on our smartphones than


was available in these early models.
4/21

What is a Computer?
A computer is an electronic device,
 In 1994,
operating under reports
the control of
 31%
instructions storedcancelled
in its own Produces
information
memory, that53% canmore thandata,
accept 2x over budget
(output)
process the data according to
specified rules, produce results, and
store the results for future use. Processing
Information processing cycle is
the series of input, process, output,
and storage activities. Collects data
(input)
5/21

What is a Computer?
 In 2014, reports
 31.1% total failure, cancelled
 52.7% over budget
 Average 16.2% completed
 9% on-time and on-budget
6/21

Categories of Computers
• Supercomputer
• Mainframe computers
• Midrange computers
• Micro computers (personal computers)
• Mobile computers/Mobile device
• Game consoles
• Embedded Computers
7/21

Categories of Computers
Component of a Computer

Hardware Software Computer


The Components of a Computer
10/21

CPU (Central Processing Unit)


CU (Control Unit):
• Fetches and decodes instructions
• Controls flow of information in and out of
MM
• Controls operation of internal CPU
components

PC (program counter):
• points to next instruction to be executed
CPU (Central Processing Unit)
(continued)
IR (instruction register):
holds instruction currently being executed

ALU (arithmetic logic unit):


carries out all arithmetic and logical
operations
12/21
13/21

Main Memory
• Directly connected to the CPU

• All programs must be loaded into main memory


before they can be executed

• All data must be brought into main memory before


it can be manipulated

• When computer power is turned off, everything in


main memory is lost
14/21

Secondary Storage
Secondary storage: Device that stores information pe
rmanently

Examples of secondary storage:


 Hard disks
 Floppy disks
 Zip disks
 CD-ROMs
 Tapes
 Flash drives
15/21

Input/Output Devices
Input devices feed data and programs into
computers. They include:
 Keyboard
 Mouse
 Secondary storage

Output devices display results. They include:


Monitor
 Printer
 Secondary storage
16/21

Program/Software
Software/Programs: set of instructions that do specific
tasks; the instructions tell a computer to perform
necessary operations to process data (input) into
information (output).
System programs take control of the computer, such
as an operating system
Application programs perform a specific task
System Software

 Word processors • Operating system


• Utility program

 Spreadsheets Application Software


• General-purposed

 Games
• Specialized
• Apps
17/21

Programming?
Programming is the process of creating a
set of instructions that tell a computer how to
perform a task.

Programming can be done using a variety of


computer programming languages, such as
JavaScript, Python, and C++.
Programming Language

Programming language is a set of written words and


symbols that are used to write a program.

Programmer is the person who writes a program.


Overview of programming languages
5 generations of Programming Languages:

Low Level
Language

High Level
Language
The Language of a Computer

Digital signals are sequences of 0s and 1s


•Machine language: language of a computer
•Binary digit (bit): The digit 0 or 1

•Binary code: A sequence of 0s and 1s

•Byte: A sequence of eight bits


Coding Schemes
• ASCII (American Standard Code for Information Interchange)
128 characters
– A is encoded as 1000001 (66th character)
– 3 is encoded as 0110011

• EBCDIC
– Used by IBM
– 256 characters

• Unicode
– 65536 characters
– Two bytes are needed to store a character
Relationship between Compiler,
Interpreters and Programs.
• Computer programs can be written using
many languages BUT computers can only
directly recognize program written in machine
language.

• Machine language is a language that uses a


series of binary digits (1s and 0s) to represent
numbers and letters used in writing a program.
To solve this problem, programs written in other
languages such as assembly language or high
level languages, must be converted to machine
code first before the program can be
understood (executed) by the computers.

This is when language translator is needed.


Language Translator
A Language Translator is a software that
translate a program written in 2nd, 3rd or
higher-generation language into machine
language.
3 types:
Assembler
• Translates from assembly language to machine
language.
Compiler

Interpreter
Compiler

 Program that converts entire source


program into machine language before
executing it.
Interpreter

Program that translates


and executes one
program code
statement at
a time
Does not produce
object program
Why Computer Program is Important?
 Modern civilization runs on computer program/software.

 Nearly all of the products, services and innovations that


power the industrialized world depend on software.

 Since computers nowadays are able to do things so


efficiently and accurately, we use computer
programming to harness that computing power.
Why Computer Program is Important?
 Modern civilization runs on computer program/software.

 Nearly all of the products, services and innovations that


power the industrialized world depend on software.

 Since computers nowadays are able to do things so


efficiently and accurately, we use computer
programming to harness that computing power.
Importance of Good Computer
Program
 Good program deliver the required functionality and
performance to the user and should be maintainable,
dependable and acceptable.

 Good program will be trusted and accepted by the users


for which it was designed.
Program Development Life Cycle
The problem solving phases are series of
steps programmers use to build computer
programs.
– Analysis
– Design
– Implementation
– Testing/Debugging
– Maintenance
Programming paradigm

A programming paradigm is a paradigmatic


style of programming.

A programming paradigm is a model for a class


of programming languages that share a set of
common characteristics and its differences.
Imperative paradigms
– Describes computation in terms of a program state
and statements that change the program state.

– Most computer languages are in the imperative style

– Key features: stored memory, sequencing, selection,


iteration, array and pointers

– Example: FORTRAN, COBOL, Pascal, Algol, BASIC


Object Oriented paradigms
– Based on imperative style with added data + abstraction and
encapsulation.
– allowing the programmers to write reusable, extensible code
that operates in a way that mimics the real world, thus allowing
programmer to use their natural intuition about the world to
understand the behavior of a program and construct
appropriate code

– Key features: Abstraction, Encapsulation, Polymorphism,


Inheritance
– Example: Smalltalk, Java
Functional Paradigm
Functional programming emphasizes the definition of functions.

Alternative paradigms for describing computation come from mathematics

Sometimes called applicative language

Involve of actual evaluation of function, passing values as parameter and


return value.

Lambda calculus forms the basis of almost all functional programming


languages.

Key features: no notion, no iteration, no assignment variable but function and


expression and recursive.

Example: Haskell, Miranda, LISP, Scheme


Logic Paradigm
– Based on symbolic logic
– The point of logic programming is to bring the
style of mathematical logic to computer
programming
– Logic provides way to prove whether the question
is true or false.
– No need for control abstraction
– Sometimes called declarative programming.
– Example: PROLOG
THANK YOU…

You might also like