You are on page 1of 24

CSC 103

Computer Program
What is a Computer Program?
• A computer program, or just a program, is a sequence of instructions,
written to perform a specified task with a computer. A computer requires
programs to function, typically executing the program's instructions in a
central processor. Computer programs are written by computer
programmer.
• Programmer are professional in computing that write programs using
different computer programming languages
Programming languages are categorized into
• Machine Language: Machine language consists of binary code (0s and 1s) that directly instructs
the computer's CPU. Each instruction corresponds to a specific operation that the CPU can
perform.
• Assembly Language: Assembly language uses mnemonic codes to represent machine
instructions. These mnemonic codes are then translated into machine language instructions by an
assembler. Assembly language provides a more human-readable format compared to machine
language.
• High level language: is computer (programming) languages that are easier to learn; uses English
like statements. Examples are C ++, Visual Basic, Pascal, Fortran, Python and C# etc. Program
written in high level language need to be translated into machine readable code using Language
translators
Types of language Translators(Interpreter
and Compiler)
• An interpreter is a computer program that directly executes, i.e. performs, instructions
written in a programming or scripting language, without previously compiling them into a machine
language program.
• An interpreter translates high-level instructions into an intermediate form, which it then executes.
• A compiler translates high-level instructions directly into machine language. An interpreter is
a computer program that directly executes, i.e. performs, instructions written in a programming
or scripting language, without previously compiling them into a machine language program.
• An interpreter translates high-level instructions into an intermediate form, which it then executes.
In contrast, a compiler translates high-level instructions directly into machine language.
• Compiled programs generally run faster than interpreted programs.
Motivation for Computer Program

• Computer program is the object that drives the computer to work. It


provide the required instructions for the computer to function as expected
by the end user. It create the interface between the human end user and the
internal component of the hardware. Therefore the computer program
drives the computer hardware.
Categories of People Involved in Programming

• The person that write computer program is called a computer programmer.


Computer programmer can be categorized into: system programmer,
application programmer, web programmer, game programmer.
Program Development Steps/Stages
The following are the steps involved in program development in a chronological order:

• Step 1: Problem Identification Understand the Problem


• Step 2: Problem analysis understanding real-world problems and user's needs and proposing solutions to meet
those needs.
• Step 3: Logic design using pseudocode or flowchart
• Step 4: Coding: translate the algorithm into a programming language
• Step 5: Program testing to detect program errors and hence correct them.
• Step 6: Program implementation.
• Step 6: Documentation
Note that in each of the stages above, proper documentation is required with the view of keeping the records and
details of activities in each stage. Proper documentation makes it easy for quick understanding of the program
details by people that were not involved at the initial development of the program.
Algorithm Development

• Before writing one piece of computer code, it is important to know what


the program is supposed to do. Hence going straight to coding can be very
confusing. It is a good idea to write a program in a simple way first to
ensure that all requirements are included before writing one line of code in
any language. Thus this can be achieved using Algorithm.
What is Algorithm?
• An algorithm is a systematic logical approach used to solve problems in a
computer.
• It is a finite set of steps defining the solution of a particular problem.
• An algorithm can also be defined as procedure consisting of a finite set of
unambiguous rules (instructions) which specify a finite sequence of
operations that provides the solution to a problem, or to a specific class of
problems for any allowable set of input quantities (if there are inputs).
• An algorithm is a step-by-step procedure to solve a given problem.
Qualities of Good Algorithm
A good algorithm must possess the following qualities:
• There must be input data for process.
• An algorithm must produce an output.
• Algorithm must be definite.
• Algorithm must be unambiguous
• Algorithm must be finite.
• Algorithm must be effective
Forms of Algorithm
Algorithm can be in two forms. They are: Pseudocode and Flowcharts.
Pseudocode
• Pseudocode is a simple way of writing programming code in English like statement. It is not
a programming language. It make use of short phrases to state the instructions of a program.
Flowchart
• A flowchart is a graphical representation of the sequence of operations in a program.
Flowcharts show how data flows from source documents through the computer to final
distribution to users. Flowcharts show the sequence of instructions in a single program
or subroutine. Different symbols are used to draw each type of flowchart. Flowchart can be
categorized into: Document flowcharts, Data flowcharts, System flowcharts, Program
flowchart
Example 1: Write the pseudocode to calculate the sum
and average of any two numbers.

Solution Pseudocode for calculate sum and average of two numbers


• Step1 : Start
• Step2 : Read two numbers a, b
• Step3 : Calculate sum=a+b
• Step4 : Calculate avg=sum/2
• Step5 : Print sum,avg
• Step6 : Stop
FLOWCHARTS
• A flow chart is a graphical representation of a process, showing the steps involved and
the order in which they are executed.
Components of a Flow Chart:

• Start/End(Terminator) Symbols: Represent the beginning or end of the process.


• Process Symbols: Represent actions or operations.
• Decision Symbols: Indicate decision points.
• Input/Output(Data) Symbols: Represent data input or output.
• Flow Arrows: Show the direction of the process flow.
Advantages of Flow Charts:

• Provides a visual representation of the process.


• Enhances understanding of the logic and flow.
• Assists in identifying errors and inefficiencies
Guidelines for Creating Flow Charts:

• Use standardized symbols.


• Keep it simple and concise.
• Use consistent flow arrow direction.
• Test the flow chart with hypothetical inputs.
FLOWCHART SYMBOLS
Predefined
Multidocum Decis
Process Process
ent ion

Data(I/
Connect Terminator O)
Sort or

Merg Document
e Col
Display late
Example 1: Draw a flowchart to calculate the sum and average of any two numbers.

Start

INPUT A,B

SUM= A+B

AVG=SUM/2

PRINT SUM, AVG

STOP
Introduction to using personal computers
hardware and software.
• Hardware and software are two terms you've probably heard of at some
point or another. We use both on a daily basis, whether it's with your
smartphone or personal computer. Let's take a deeper look at what these
two things are and why they're important.
• Hardware is any element of a computer that's physical. This includes
things like monitors, keyboards, and also the insides of devices,
like microchips and hard drives.
Software
• Software is anything that tells hardware what to do and how to do it,
including computer programs and apps on your phone. Video games,
photo editors, and web browsers are just a few examples.
Hardware and Software
• Hardware and software are different from each other, but they also need
one another in order to function. Let's look at an example of this using a
smartphone. In this case, the hardware would be the physical phone itself,
and the software would be its operating system and apps.
• If we were to take away the software, we would just have a dead phone in
our hands. It wouldn't be able to make calls, text, or go online because
it's not receiving any instructions.
• On the other hand, let's say we have no hardware, meaning there's no
actual phone. If all we have are the programs, we just have a bunch of
instructions but nothing to give these instructions to.
• Hardware needs software to tell it what to do, but software also needs
hardware in order to act out its directions. When you combine the two,
you can do all sorts of things, whether you're using a smartphone,
computer, or any other type of device.

You might also like