It103 Week1

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 28

IT103

Eugene Perez
A program is a set of instructions that tell the
computer to do various things; sometimes the
instruction it has to perform depends on what
What is
happened when it performed a previous
Programming? instruction.

Programming is a process of writing programs.


It is the process of coming up with the correct
methodology (how to do thins) to develop program
Program Logic logic that solves a computer problem. Program
Formulation logic is the computer processing steps needed to
break down a problem into smaller less complex
tasks which eventually solve the problem.
Programming languages are the languages used to
communicate with a computer

E.g., C++, C#, Java, Visual Basic, Perl, C, COBOL


Programming
Languages
Types
1. Machine languages
2. Assembly languages
3. High-level languages
• The first programmers had to write the
program instructions using only combinations
of 0s and 1s
▫ E.g., 00101 10001 10000
• Instructions written in 0s and 1s are called
Machine machine language or machine code
Language • Each type of machine has its own language
• Machine languages are the only way to
communicate directly with the computer
• Programming in machine language is tedious
and error-prone; requires highly trained
programmers
• Assembly languages simplify programmer’s job
• Can use mnemonics instead of 0s and 1s
▫ E.g., ADD bx, ax
Assembly
Language • Assembly programs require an assembler to
convert instructions into machine code

• Easier to write programs in assembly language


▫ But still tedious and requires highly trained
programmers
 High-level languages allow programmer to use
English-like instructions

 E.g., grossPay = hours * rate

 High-level languages are more machine-


High-Level independent

Language  Programs written in a high-level language can be


used on many different types of computers

 Compilers convert the instructions into 0s and 1s

 Interpreters translate the program line by line as


the program is running
 When writing a procedure-oriented
program, the programmer concentrates on
the major tasks that the program needs to
perform
High-Level  Examples: COBOL, BASIC, C
Language
 An object-oriented program requires
programmer to focus on the objects that the
program can use to accomplish its goal

 Examples: C++, Visual Basic, Java, C#


The computer is basically a problem-solving tool.
Once it is properly provided with a valid program,
the computer becomes self-operational, that is, it
requires no human intervention during processing.
Program Cycle
The programming cycle serves as a general guide
on how we come up with a program before during,
and after.
5.0
1.0
Documentation
Defining the
and
Problem Maintenance

Programming 2.0
4.0

Cycle Planning
Checking
out the
the Solution
Program

3.0
Coding the
Solution
1. Defining the Problem
 Understand the problem. The
programmer cannot start without
understanding the problem

Program Cycle What has to be done?


What problem needs to be solved?
What are the needs of the user?
 Identifying the input and output
requirements
 The scope and limitations
2. Planning the Solution
 Select the best method for solving it.
 Involves determining the sequence
Program Cycle of processing steps
 Can create flowchart as pictorial
representation
 Select the appropriate programming
language to be used.
3. Coding the Solution
Program Cycle  The programmer converts the program
flowchart into readable instructions that
make up an actual program.
4. Checking out the Program
 Involves debugging and testing.

Debugging – the task of finding erros(bugs) and correcting


them so that the program runs correctly.

2 Types of Errors
Program Cycle
a. Syntax Errors – occur in coding the data
b. Logical Errors – errors which are hard to detect. They
occur because the programmer does not thoroughly
understand a phase of the problem to be solved.

Testing – consists of running the program with input data that


simulates the actual data that will be processed by the
program.
5. Documentation and Maintenance
 After the program has been fully tested and
implemented, the programmer must write the full
Program Cycle specifications for all users.
 The purpose of this is for the program to execute
and be modified without requiring the original
programmer’s assistance.
 A set of rules that precisely defines a sequence of
operations
 A list of instructions for carrying out some process
step by step

Algorithm
Algorithms are essential to the way computers process
data. Many computer programs contain algorithms that
detail the specific instructions a computer should
perform (in a specific order) to carry out a specified
task, such as calculating employee’s paychecks or
printing student’s report cards.
Three Categories of Algorithmic Operations/Logic or
Control Structures:
1. Sequential Operations – Instructions are executed in
order.
2. Selection / Conditional (“question asking”)
Algorithm operations – a control structure that asks a true/false
question and then selects the next instruction based
on the answer.
3. Repetitional/ Iterative operations (loops) – a control
structure that repeats the execution of a block of
instructions
 Programs are written using three basic
structures

 Sequence
 Used in every program you write

Algorithm  Repetition
 Used in most programs you write

 Selection
 Used in most programs you write

 Called control structures or logic


structures
• The sequence structure directs the computer to
Sequence process the program instructions, one after
another, in the order listed in the program
• Selection structure: makes a decision
and then takes an appropriate action based
Selection on that decision

▫ Also called the decision structure


• Repetition structure: directs computer
to repeat one or more instructions until
some condition is met

Repetition ▫ Also called a loop or iteration


1. Natural Languages
 User formal programming languages
 Too low level
 Requires us to deal with complicated syntax of
How to programming language
represent 2. Pseudocode
algorithms?  Natural language constructs modeled to look like
statements available in many programming languages.

3. Flowchart
 Graphical representation of the sequence of operations
in an information system or program.
 An artificial and informal language that helps programmers
Pseudocode develop algorithms.
 Pseudocode is a “text-based” detail (algorithmic) design
tool
 A graphical representation of an algorithm
 A diagram representing logical sequence in which a
combination of steps or operations is to be performed
 A pictorial representation in solving a problem.

Types of Flowchart
Flowchart 1. Program Flowchart
 Describes graphically in detail the logical operations and
steps within a program and the sequence in which these steps
are to be executed.
2. System Flowchart
 A graphic representation of the procedures involved in
converting data on input media into output form.
 Little is shown about how processing will be accomplished.
 Any letter, or combination of letters and digits to store data
or result of computation process.

In most programming languages, there are certain rules in


assigning variables. For the benefit of this subject, these rules
must be follow.
Variables 1. It should always start with a letter
2. Spaces and special characters are not allowed.
3. Underscore can be used in variables
4. Uppercase and lowercase variables are treated differently.

Ex: N,X, num, N2, num1, Average, TotalSales, Final_Rating


Commonly Used flowcharting symbols:
Terminal
 Used to designate the beginning and end of a program or a point
of interruption.
I/O
Flowchart  Represents an instruction to an input/output device. Input
instructions like READ, INPUT, GET, ACCEPT, and output
instructions like DISPLAY, PRINT are some of the keywords which
are used in this symbol.

Processing
 Used to represent a group of program instructions that perform a
processing function such as arithmetic operations.
Preparation/Initialization
 Used to represent a group of program instructions that will alter or
modify a program’s course of execution, and is used to initialize
values.
Decision
 Denotes a point in the program where more that one path can be
taken.
On Page Connector

Flowchart  Used to connect one part of a flowchart to another found on the


same page
Off Page Connector
 Used to connect one part of a flowchart to another found on
another page.

Flow lines and Arrowheads


 Used to direct the processing flow and show reading order or
sequence.
1. Use proper flowcharting notations.
2. Do not use curved lines to connect symbols.
3. Use only one start and one stop per flowchart.
4. The logic flow of the solution is displayed from top to bottom and
from left to right.
5.
Rules in Use the appropriate symbol with appropriate phrase for each type
of operation.
Drawing a 6. Use connectors when moving to another part of the flowchart rather
than lines to simplify your flowchart.
Flowchart 7. Questions in flowcharts are asked in a yes/no format using decision
symbol. Complete both the yes side and the no side for each
question asked in the flowchart.
8. Do not leave dead-ends – ensure that the flowchart will begin on the
Start symbol, and ends on the Stop symbol – that is, one way in and
one way out of the flowchart.
9. Trace the flowchart to ensure the correctness of the solution.
10. Redraw and simplify your flowchart solution

You might also like