You are on page 1of 43

INTRODUCTION

TO
PROGRAMMING
COMPUTING

Computer is a device which can process data, perform


computation and logical operations and gives output

A computer performs the above under program


instruction and without human intervention
COMPUTER HARDWARE, SOFTWARE AND FIRMWARE

Hardware the physical devices of a


computer
Software the programs or intelligence of
the computer
Firmware programs that are built-in with
the hardware
SOFTWARE

Software a group of programs


Program a specific set of instructions to
the computer to perform a task
Programmer a person who writes
computer programs
DATA AND MEMORY

Memory unit: Area to store data and instructions


Data Raw pieces of information
Number, Text, Sound, Graphics, Animation
Data stored in memory as On or Off pulses
DATA REPRESENTATION

Represented by a combination of eight binary digits (1s


and 0s)
Binary code used to represent all characters
ASCII American Standard Code for Information
Interchange
ASCII REPRESENTATION

From 00000000 to 11111111; each assigned to a unique


character.

A number
is stored in memory in its binary equivalence
read as character using its ASCII character
NUMBER SYSTEMS

Decimal 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Binary 0, 1
Octal 0, 1, 2, 3, 4, 5, 6, 7
Hexadecimal system 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C,
D, E, F
BINARY AND DECIMAL SYSTEM

Binary to decimal
X . 27 + X . 26+ X . 25+ X . 24 + X . 23+ X . 22+ X . 21 + X . 20
Decimal to binary
o Keep dividing the number by two and keep track of the remainders.
o Arrange the remainders (0 or 1) from the least significant (right) to most
significant (left) digits
TO OCTAL AND HEXADECIMAL SYSTEM

Binary to Octal (8 = 23)


oEvery 3 binary digit equivalent to one octal digit
Binary to Hexadecimal (16 = 2 4)
oEvery 4 binary digit equivalent to one hexadecimal digit

Octal to binary
oEvery one octal digit equivalent to 3 binary digit
Hexadecimal to binary
oEvery one hexadecimal digit equivalent to 4 binary digits
MACHINE LANGUAGE

Executable programs are written with binary


numbers, which is a computers internal
language (machine language)

The only language that the computer can


understand and execute
MACHINE LANGUAGE
PROGRAMMING LANGUAGE

An agreed-upon format of symbols that enables


a programmer to instruct a computer to perform
a pre-defined task

Powerful tool to build programs and software


HISTORY OF PROGRAMMING

Machine Language - Manually flipped switches


in binary codes
Assembler language
o use of a series of mnemonics to represent commonly
used instructions
o stored on punch cards
Programming Languages
o E.g. COBOL and FORTRAN
HISTORY OF PROGRAMMING
EARLY PROGRAMMING
LANGUAGE

COBOL Common Business Oriented Language


used primarily for business processing
FORTRAN (Formula Translation) primarily
perform mathematical calculations
Use of compiler as a translator
LATER PROGRAMMING
LANGUAGES

PL/I, BASIC, Pascal, Prolog, C, Ada


- Procedural programming

C++, Visual Basic


object-oriented programming

HTML, Java
programing for web-based applications
ADVANTAGES OF
PROGRAMMING LANGUAGES

Performs quicker
More adaptable to different system
Similar to human language
TRANSLATION OF PROGRAMMING CODES

Machine language: the only language understood or


processed by computer
All programs (source code) must be translated to machine
language to be executed (object code)
Use of program translator:
o Interpreter: translated and executed at once, line by line
o Compiler: translated and stored into executable (.EXE) file.
THE MAKING OF A QUALITY
PROGRAM

readability
modularity
efficiency
robustness
usability
READABILITY

understandable, with adequate comments


and documentations, using conventions
like name of variables and indentations
MODULARITY

problems divided into sub-problems and


assembled in a logical order
EFFICIENCY

runs faster and smaller size of program


ROBUSTNESS

Be able to handle all situations in a graceful manner


Not to crash in unexpected situations or go to
infinite loops.
USABILITY

correct, meets the end-user requirement


PROGRAM PLANNING
AND DESIGN

Important Stages to Solve


Programming Problems
STEPS TO
PROBLEM-SOLVING
Analysis of the problem and developing
specifications / requirements
Designing solutions
Coding of the program
with documentation
Testing the program
Maintenance of the program
STEPS TO PROBLEM-SOLVING
ALGORITHM

The sequence of steps required to solve a problem


PRESENTATION OF ALGORITHMS

Structure Chart: structure of modules needed


to solve a problem

Pseudo-codes: English-like list of steps of the


algorithm.

Flow-charts: Graphical representation of an


algorithm
STRUCTURE CHART

To chart out the modules and statements


break down a programming problem into sub-problems
PSEUDO-CODE

Semi-formal, English-like description of logic of an


algorithm
Helps programmer to think out the program
Advantage:
o Simple
o Effective
EXAMPLE OF A PSEUDO-CODE

To calculate Sales Amount:

1. First get user to enter quantity

2. Get the price of the product

3. Calculate amount = price X quantity

4. Display the amount


FLOW-CHARTS

Graphical representation of an algorithm

Uses symbols and shapes to describe flow or sequence


of process to solve a problem
FLOW-CHARTING
SYMBOLS

Terminators

Process Decisions

Connectors

Input/Output Loop
Direction
of Flow
SAMPLE FLOWCHART
SAMPLE CODING
PROGRAM
DOCUMENTATION

Beginning and interim remarks /


comments to be added to program
codes to make it more understandable
IMPORTANCE OF
DOCUMENTATION

For debugging purposes


Program modification purposes
DEBUGGING

a process to remove error


error = bug, the first computer bug is a bug
found on a printer
4 kinds of errors :
o syntax error
o Run-time error
o Undetected error
o logic/semantic error
KINDS OF ERRORS

Syntax error Violation of syntax rules, not source code to be


compiled
Run-time error Program can be compiled, but is halted during
execution, e.g. Division by zero, data overflow
Undetected error program can be compiled and run
completely but with some errors in the output
logic/semantic error error in the logic or faulty algorithm
END OF SLIDES

You might also like