CHAP 1: INTRODUCTION TO PROGRAMMING
Chapter 1
INTRODUCTION TO COMPUTER AND PROGRAMMING (4 HOURS)
Introduction to the computer and programming concepts
System Development Life Cycle phases
Definition of an essential programming design
through algorithm development: pseudo code and flowchart
Milestones in computer history..
Please refer to the following book if you want to know more about the history and evolution of computer..
by Shelly, Cashman and Vermaat
Introduction to C language (assignment)
Example
Who developed C language?
When C is introduced?
etc
Chap 1 Introduction to Programming
LEARNING OBJECTIVE
After this lesson, student should be able to understand or explain about:
The history of computing
Computer programming concept
Components of computer programming
The Software Development Method
Chap 1 Introduction to Programming
An electronic device
Operating under the
control of instruction stored in its own memory
Accept data
Process data according to specific rules
Produce results
Store results for future use
What?
Why?
How? When?
Programming language
Computer program
Terminology Computer Programming Programmer
Source code
Computer program
•Also known as software
•List/sequence of instructions to computer
consists of specific steps to be carried out by computer
Instruct computer to do task or data processing to produce useful information
How it works?
What ?
Example of computer program
An example of a computer program or software written in C programming
language
A series of instructions that tells a computer what to do
and how to do a task.
We can say that……
any sequence of statements and/or declarations written
in some human- readable computer
programming language.
Also known as code snippet or
program code
One part of the whole computer
program.
What ?
#include <stdio.h>
int first,second;
void addition(int x,int y);
void main() {
printf("Enter first number:");
scanf("%d",&first);
printf("Enter second number:");
scanf("%d",&second);
}
void addition(int x,int y) {
add = x + y;
printf("The result of a + b = ",add);
}
Source code Source code
Example of source code
Computer Programming
The process of writing, testing and maintaining the source code of the computer program
•Requires knowledge in the application domain
•Follow the steps in software development method
How to program ? What ?
?
To solve the problems occurred in life with the assistance of
computer
To help improve daily process e.g: transaction,
payroll,accounting, registration, information
exchange etc.
Programming is a
problem-solving activity
Programming Language
A set of symbol, word, code or instructions which is understood by
computer
Method of communication for which computers could understand and execute
the instructions written in source code.
Function?
What ?
?
Computer languages
Category Explanation
Machine language Binary number codes understood by a specific CPU
Assembly language
Mnemonic codes that correspond to machine language instructions
High level language
Machine-independent programming language that combines algebraic expressions and English symbols.
Computer programmers usually only involve in writing high level language
Examples of programming language
Language Application Area FORTRAN Scientific programming
COBOL Business data processing LISP Artificial Intellingence
C System programming
C++ Supports objects and object-oriented programming
Java Supports object-oriented, Web and mobile programming.
High level programming
languages
An example of a computer program or software
written in JAVA programming language
Example of computer program
An example of a computer program or software
written in C++
programming language
Example of computer program
Computer programmer
Those who are responsible to write
computer programs What ?
How ?
Job involves requirement analysis, specification, software architecture,coding, compilation, software testing, documentation,integration and maintenance.
Programming language
Computer program
Terminology Computer Programming Programmer
person
The Concept of Computer Programming
Input
Output
Input Output Process
Computer process data into information
Components of computer programming
Any data and instruction
entered into the memory of a computer
Data
A collection of
unprocessed items e.g:
text, numbers, images, audio and video
Computer mouse Keyboard
is a naturally occurring or
designed sequence of changes of properties or attributes of an
object or system
In computer processing, data is turned
into useful information
Data that has been
processed into a useful form (information)
Information
result of processing, manipulating and
organizing data in a way that adds to the knowledge
of the receiver
A computer generates several types of
output, depending on the hardware and software being used and user requirements
in text,
graphics, audio or video forms.
Monitor Printer
Computer programmer
WHAT Program ??
Also known as Software/
System Development Life Cycle
(SDLC) or software process
A development of a
software/computer program product.
Steps used to solve problem in computer programming
Specify problem Analyze problem Design algorithm Implement algorithm Test and verify program Maintain and update program
Steps
STATE
What
problem to be solved?
What is the problem?
Is it possible to solve the problem with
programming?
State the problem
clearly Gain a clear
understanding of what are
required for its solution.
Given the value of x is 10 and a is 12,
find the result of the following equation:
y = 2x + a - 6
What is the problem?
Is it possible to solve the problem
with
programming?
What to solve?
Problem What is the value of y?
Data Given the value of x and a
Solution Solve the equation using the given values
State the problem clearly
Uncle John wants to buy 5 tins of paint from Cinda’s shop. The price of each tin of the paint is
RM 15.60. Calculate the price which Uncle John have to pay for all the tin of paints he bought.
What is the problem?
What to solve?
What data we have?
Problem What is the price for 5 tins of paint?
Data Given the price for one tin of paint
Solution Calculate the price of one tin of paint with the amount of the paint tin
State the problem clearly
Mrs Sue needs to determine her students grade for programming subject based on the mark scored during final examination. The ‘A’ grade will be given if the mark
scored is between 85 to 100. If a student has scored 90 marks, what is the grade should Mrs Sue give to the
student?
What is the problem?
What data we have?
What is the solution?
Problem What is the grade?
Data ‘A’ will be obtained if mark is between 85 to 100. The student’s mark is 95.
Solution Determine the grade based on the mark State the problem clearly
A box has height, width and length.
Calculate the volume of a box.
Problem Volume of a box
Data Box has height, width and length
Solution Get the height,width and length of a box.
Create formula for the box volume
Calculate salary of an employee for a month.
Problem Salary for a month
Data No specific data.
Pay per day,working days
Solution Get the pay per day and amount of working days.
Calculate the salary.
IDENTIFY
Input Output
Process
Given the value of x is 10 and a is 12,
find the result of the following equation:
y = 2x + a - 6
Input
Output
Process
Input Value of x and a
Process Replace the value of x and a in the formula, y = 2x +a -6
Output The value of the equation, y
Identify the problem
Uncle John wants to buy 5 tins of paint from
Cinda’s shop. The price of each tin of the paint is RM 15.60. Calculate the price which Uncle John have to pay for all the tin of paints he bought.
Input Process Output
Input Amount of paint tin, price per tin
Process Develop a formula(s):
payment = amount x price per tin
Output Payment for the paint(s) Identify the problem
Mrs Sue needs to determine her students grade for
programming subject based on the mark scored during final examination. The ‘A’ grade will be given if the mark scored is between 85 to 100. If a student has scored 90
marks, what is the grade should Mrs Sue give to the student?
Input Process Output
Input Mark
Process If mark is between 85 and 100, grade will be A
Output Grade
Identify the problem
Given the following formula, calculate the porosity of rock:
porosity = (pure volume /total rock volume) x 100%
Specify and analyze the problem
Compute and display the total cost of apples given the number of pounds of
apples purchased and the cost of apples per pound.
Develop a list of steps called algorithm
Verify that the algorithm solves the problem
Solve Problem
Convert algorithm into programming
Writing program
Also known as CODING
Coding
General steps involved
Documentation Compile
Execute/Run
Write program code with specific programming language in specific
programming tools/software
Write explaination/description for each line of codes/comment for future
references
Using tool/software function to check errors in program code
Using tool/software function to display output of program
To verify the program can works as desired
Testing program
Executing program to see if it produce correct results.If not
do debugging.
Remove undetected errors and keep up-
to-date
Modifying program
USE and MODIFY the program to meet
changing
requirements or correct errors that show up in using it
Specify problem Analyze problem Design algorithm Implement algorithm Test and verify program Maintain and update program
Steps
EXAMPLE
Drink Stall
State the Problems clearly
customers come no matter the time
1 worker
Time to pray? Eat? ????
Auto transaction (customer)
Drink Stall
State the Problems clearly
Problem = How much to pay?
Data = Number of item, Price per item
Solution = calculate number of item with price per item
• Without changing the steps
Analyze the problem
Input : type of drinks, number of drinks
Process : calculate the total price according to type of drinks and number of drinks
Output : Price to pay