Module 1 - Intro To Programming

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

CCS0003

COMPUTER PROGRAMMING 1
LESSON #1

Introduction to
Programming

Introduction to Programming
Upon completion of this module, you will be able to:
• Define what is computer programming
• Define terms related to computer programming such as
source code, programs, etc.
• Know the difference between an Assembly Language and
Machine Language
• Describe what are the low and high-level languages
• Know the difference between procedural and object-
oriented programming
• Identify the steps in program development

Introduction to Programming
Programming is a multistep process
for creating a program.

It is a way of giving computers


instructions about what they should
do next. These instructions are
known as code.

Introduction to Programming
WHY PROGRAMMING IS IMPORTANT?

APPRECIATING THE ART OF


COMPUTER CODING

Introduction to Programming
• Programming is important for
learning to innovate, create eco-
Programming is important
friendly solutions for global to automate, collect,
problems. manage, calculate, analyze
the processing of data and
• Programming is important for information accurately.
speeding up the input and
output processes in a machine.

Introduction to Programming
COMPUTER PROGRAMMING TERMS

Introduction to Programming
• A computer program is a list or sequence of instructions that
tell a computer what to do.
• Everything a computer does is done by using a computer
program.
• A computer program is written in a programming language.

Introduction to Programming
• A programming language (PL) is a type of written language that
tells computers what to do in order to work.
• Programming languages are used to make all the computer
programs or software.
• Each PL has its own grammar called syntax. It consists of rules
governing the structure and content of the statement that should
be followed.
• A programmer writes source code using a programming
language to create programs.

Introduction to Programming
• Source code is a well-written set of instructions and
statements to develop a program.
• Source code can be written in low-level or high-level
language.
• Source code must be translated to machine language
(binary form) using a language translator.

Introduction to Programming
• Assembler translates a program written from an assembly
language to a low-level language.
• Interpreter translates each statement or one line at a time and
executed immediately after translation.
• Example: JavaScript, Python, Ruby
• Compiler translates all statements at one time. It provides all
the error messages – called diagnostics- at once.
• Example: C, C++, Java

Introduction to Programming
• Low-level Language • High-level language
• uses instructions tied • uses English-like
directly to one type of instructions and can be
computer. run on a variety of
• often cryptic and not computer types.
human-readable.
Examples: Examples:
machine language, assembly Visual Basic, C, C++, Java
language

Introduction to Programming
Introduction to Programming
ASSEMBLY LANGUAGE C++ LANGUAGE

LOW-LEVEL HIGH-LEVEL

Introduction to Programming
Within a computer, all data is
represented by microscopic • Instructions written in 0s and
1s are called machine
electronic switches that can be language or machine code.
either OFF or ON.
• Each class of computer has its
• OFF switch is designated by a 0.
own particular machine
• ON switch is designated by a 1.
language
• Writing in machine language
Example: is tedious!
00101 10001 10000

Introduction to Programming
A programming language with
Assembly language programs
symbolic names for opcodes,
must be translated into machine
and decimals or labels for
instructions, using an assembler.
memory addresses

Example:
ADD 1, 2
MUL 2, 3

Introduction to Programming
PROCEDURE vs OBJECT-ORIENTED
PROGRAMMING

Introduction to Programming
• Procedure-oriented program, the programmer concentrates
on the major tasks that the program needs to perform. The
programmer must instruct the computer every step of the way,
from the start of the task to its completion.

Example:
In a payroll program, the program typically performs several
tasks, such as inputting the employee data, calculating the
gross pay, taxes, net pay, and outputting a paycheck.

Introduction to Programming
• Object-oriented program requires the programmer to
focus on the objects that the program can use to
accomplish its goal. The objects can take on many different
forms.

Example:
In Windows-based program, it typically use objects such
as check boxes, list boxes, and buttons.

Introduction to Programming
PROCEDURAL PROGRAMMING OBJECT-ORIENTED PROGRAMMING

Where:
Rotate(shapeNum) and
playsound(shapeNum) are functions
Where:
Shape is the class; Circle, Rectangle and Polygon are the objects.

Introduction to Programming
STEPS IN PROGRAM DEVELOPMENT

Introduction to Programming
1. Requirement Analysis
2. System Design
3. Coding or Writing The Program
4. Testing and Validation
5. Documentation and Maintenance

Introduction to Programming
• Requirement is a description of what a system should do.

• It involves the collection of information and the definition of the


characteristics or features of the desired system.

Introduction to Programming
• Problem Analysis requires performing the following steps:
• Define the problem and the users.
• Determine the desired outputs.
• Determine the input to achieve the desired outputs.
• Determine the processes involve.
• Check the feasibility of implementing the program.
• Document the analysis.

Introduction to Programming
• The program design process describes the algorithm for the
solution of the problem.
• An algorithm is the step-by-step sequence of instructions that
describe how data will be processed to produce the desired
output.
• To formulate the algorithm, a programmer may choose between
pseudocodes or flowcharts.

Introduction to Programming
• Pseudocode is an algorithm written in normal Human language
statements to describe the logic and processing flow.
Example:
If the list of payroll tasks(algorithm) looks The pseudocode would look like this:
like this: READ name, hourly rate, hours worked,
• Get the employee name, hourly rate, deductions
hours worked, deductions CALCULATE: Gross pay = hourly rate times
• Calculate the gross pay and net pay hours worked
• Write name, gross pay and net pay CALCULATE: Net pay = Gross minus
deductions
WRITE name, Gross pay, Net pay

Introduction to Programming
• Flowchart is a visual Example:
representation of the sequence
of steps and decisions needed
to perform a process.
• Each step in the sequence is
noted within a diagram shape.
• Steps are linked by connecting
lines and directional arrows.

Introduction to Programming
• The actual writing of the program based on the design
specifications (coding).
• The design specifications describe how a system performs
the requirements.
• Construction requires performing the following steps:
• Select the appropriate programming language.
• Follow the syntax.

Introduction to Programming
Program testing involves running various tests, such as desk
checking and debugging – called alpha testing, and then
running actual or real data to make sure the program works.

Testing and validation requires the following steps:


1. Perform desk-checking
2. Debug the program
3. Run real data

Introduction to Programming
1. Desk checking is manually testing the solution design to
make sure that it is free of errors and that the logic works.
2. Debugging means detecting, locating, and removing all errors
in a computer program.
Types of Errors
• Syntax Error is the most common error and incorrect use of
programming language statements.
• Run-time Error is a software error that occurs while a program is
being executed.
• Logical Error is a mistake in a program's source code that results in
incorrect or unexpected behavior.
3. Run real data

Introduction to Programming
When the program is finalized, its documentation is prepared.
• Documentation is a written detailed description of the
programming cycle and specific facts about the program.
Also, it includes necessary instructions on the use and
maintenance of the program/software (product).
• Maintenance is any activity designed to keep programs
error-free, up-to-date and in good working condition.

Introduction to Programming
ASK ANY QUESTION RELATED TO
OUR TOPIC FOR TODAY.

Introduction to Programming
Introduction to Programming

You might also like