CSC126 CH1
CSC126 CH1
INTRODUCTION TO
PROGRAMMING
CSC126 | FUNDAMENTALS OF
ALGORITHMS AND COMPUTER
PROBLEM SOLVING
Topics
• Introduction to computer program
• Program Development Life Cycle (PDLC)
• Details of problem analysis
• Algorithm Design & Implementation
• Basic control structures
INTRODUCTION TO
COMPUTER
PROGRAMS
Computer Programs
• Program: A set of instructions that the computer needs to follow to
process the data into information.
• Computer program: A sequence of instructions that the computer
carries out to fulfill the task.
• Computer programmer: A person who writes a computer program.
• Computer programming: The act of designing and implementing
computer programs using the programming languages.
• Programming language: Provides a way to program a computer using
instructions that can be understood by computers and human. It has
its own vocabulary and rules of usage.
Computer Programs
Computer :
• An electronic machine, operating under the control of instruction stored
in its own memory
• Machine that obtains data as input, processes the data and produces
valuable output. Output will be stored in various storage.
•Hardware : An equipment that processes data to create info. includes input, output,
storage and processing device.
Output device
• A device that computer uses to display results.
• Eg: monitor and printer.
Secondary storage
• A device that stores information permanently.
• Eg: hard disk, floppy disk, CD-ROMs and pendrive
Computer Software
System Software
• Consists of programs that manage the hardware resources of computer and perform required info
processing tasks.
• Provides an environment for user to execute the application software (interface between the
hardware and theusers).
• Enable the application software to interact with computer hardware.
• Eg: Operating System (provides services such as a user interface, file and database access and
interfaces to communication systems).
Application Software
• End user software.
A program that performs a common task to the user.
Eg: Word, Excel.
Program Development Life
Cycle (PDLC)
5. Program
maintenanc e
1. Problem 3. Algorithm and
analysis implementation doc umentation
2. Algorithm 4. Program
design testing and
debugging
This methodology consist of steps
programmers use to build
computer programs.
Program
Development The steps:
Life Cycle • 1. Problem analysis
(PDLC) • 2. Algorithm design
• 3. Algorithm implementation
• 4. Program testing and debugging
• 5. Program maintenance and
documentation
Program Development Life Cycle
(PDLC)
Step 1: Problem Analysis
• Problem is defined to obtain a clear understanding of the
problem requirement
• Define what the job is, NOT HOW.
• What program is to accomplish:
• What is the output
• What is the input
• What formula (process(s)) is to be used?
• What other assumptions or constraints can be made?
• What is the expected output screen?
Mission…
Input Output
Process:
Example: problem that can be solved
by computer
List out
Pseudocode
O A precise algorithmic description of a program logic.
O Expresses an algorithm in everyday English rather than programming language
O Describe instructions in your own word.
Flowchart
O A diagram to represent a flow of an algorithm.
Step 2: Design an algorithm
Flowchart
O A diagram to represent a flow of an algorithm.
Symbols Descriptions
O Basic flowchart:
Terminal symbol - indicates the beginning and
end points of an algorithm.
Input-output symbol - shows an input or an output
operation.
Pseudocode
Begin
Get/ Input/ Enter year born and current year
Calculate age
age = current year – year born
Print/ Display age
End
Step 2: Design an algorithm
Flowchart
Start
Input year
born, current year
Print age
End
Step 3: Implementation
• The process of writing the code that translate the design
into a computer program using a programming language.
• Different languages have different syntax.
• A language syntax’s is the set of grammar and rules that
specifies how to write instructions for an algorithm.
Step 3: Implementation
• Source code/ program
Step 4: Testing and Debugging
• Program testing requires testing the completed program to
verify that it produces expected output. A different set of
testing data is normally used to verify that the program
works properly and that it is indeed solving the given
problem.
• Also involve with process of running the program and
checking for errors. This is to ensure that the programs
works like it supposed to.
• Debugging: Process of locating and correcting errors in a
program.
Step 5: Documentation & Maintenance
Documentation
Maintenance
• Any activities to keep the program in good working condition, error free and up-to-date.
• Involves any amendments, additional coding or repairs to the programs.
BASIC CONTROL
STRUCTURE
Program control structures
• Program control structure controls the flow of execution of
program statement. C++ provides structures that will allow
an instruction or a block of instruction to be executed,
repeated or skipped.
• There are three control structures:
• Sequential structure
• Selection structure (by making a choice, which called a branch).
• Repetition structure (by executing a statement over and over using
a structure called a loop or by calling a function).
Sequential Structure
• The simplest of all the structures
• The program instruction has one starting point and one
ending point.
• Each step is carried out in order of their position and is
only done once.
Selection Control
Structure
• The selection structure allows comparison of
expression, and based on the comparison, to select
certain course of action
Selection Control Structure
• Example:
F Telephone T
rings?
false beg
has
items?
true