0% found this document useful (0 votes)
7 views

CC102 UNIT A Introduction To Programming and C-3

CC102

Uploaded by

- Rei
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

CC102 UNIT A Introduction To Programming and C-3

CC102

Uploaded by

- Rei
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 70

BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

INTRODUCTION TO
PROGRAMMING
AND CC102 - Computer Programming 1

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

DESIRED LEARNING OUTCOMES


At the end of the semester, the students shall be able to:

01
Analyze fundamental
programming concepts and
apply them to construct basic C
programs.

02
Synthesize knowledge of C syntax
and structure to effectively
represent program solutions in
code.

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

TABLE OF CONTENT

BASIC PROGRAMMING CONCEPTS


01 • Algorithms
• Flowchart
• Pseudocode

INTRODUCTION TO C
02 • Structure
• Compilation Structure

CORE SYNTAX
03 • Data Types
• Variables
• Operators
• Input/ Output

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC
PROGRAMMING
CONCEPTS
• Algorithms
• Flowchart
• Pseudocode

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


COMPUTER PROGRAMS

• COMPUTER PROGRAMS - These are the collections of instructions that tell a computer what
to do, how to interact with the user, interact with the computer hardware and process data.

• The first programmable computers required the programmers to write explicit instructions to
directly manipulate the hardware of the computer.

• Computer programs, known as software. You tell computer what to do through programs.

• Without programs, a computer is an empty machine.

• Computers do not understand human languages, so you need to use computer languages to
communicate with them.

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


PROGRAMMING LANGUAGES

• PROGRAMS - These are written using programming languages.

• PROGRAMMING LANGUAGE - It is an agreed upon format of symbols that allow a


programmer to instruct a computer to perform certain predefined tasks.

• Some types of programming languages are:

■ Machine Languages
■ Assembly Languages
■ High-Level Languages

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


TYPES OF PROGRAMMING LANGUAGES: MACHINE LANGUAGE

• MACHINE LANGUAGE - It is also known as Low-Level Language and is the only language that
can be understood by the computer.

• It is sometimes called machine code or object code.

• The machine language contains only two symbols 1 & 0. All the instructions of machine
language are written in the form of binary numbers 1s & 0s.

• A computer can directly understand the machine language.

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


TYPES OF PROGRAMMING LANGUAGES: ASSEMBLY LANGUAGE

• ASSEMBLY LANGUAGE - It is also known as Mid-Level Language in which the instructions are
created using symbols such as letters, digits and special characters.

• In assembly language, we use predefined words called mnemonics. Binary code instructions
in low-level language are replaced with mnemonics and operands in middle-level language.

• But the computer cannot understand mnemonics, so we use a translator called assembler to
translate mnemonics into machine language.

• ASSEMBLER - It is a translator which takes assembly code as input and produces machine
code as output.

• That means, the computer cannot understand middle-level language, so it needs to be


translated into a low-level language to make it understandable by the computer.

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


TYPES OF PROGRAMMING LANGUAGES: HIGH-LEVEL LANGUAGE

• HIGH-LEVEL LANGUAGE - It is a computer language which can be understand by the users.

• The high-level language is very similar to human languages and has set of grammar rules that
are used to make instructions more easily.

• Every high level language has a set of predefined words known as keywords and a set of rules
known as syntax to create instructions.

• The high-level language is easier to understand for the users but the computer can not
understand it.

• High-level language needs to be converted into the low-level language to make it


understandable by the computer.

• We use compiler or interpreter to convert high-level language to low-level language.

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


TYPES OF PROGRAMMING LANGUAGES: HIGH-LEVEL LANGUAGE

• Examples of High-Level Languages:

JAVA FORTRAN (FORmula TRANslation)


General purpose-gaining Developed for Engineering and
popularity rapidly Scientific Applications

COBOL (Common Business BASIC (Beginner All-purpose


Oriented Language) Symbolic Instructional Code)
Developed for business Developed for business
applications. applications

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


TYPES OF PROGRAMMING LANGUAGES: HIGH-LEVEL LANGUAGE

• Examples of High-Level Languages:

PYTHON
VISUAL BASIC It is a general purpose programming
Basic-like visual language developed language that’s used to do things from
by Microsoft testing microchips at Intel, to building
video games.
C++ C
it is an extension of C programming It is designed to support only
language that supports object- procedure-oriented programming.
oriented programming and procedure Popular langage for developing system
oriented approach. General purpose applications such as operating system
and most popular. and compilers.

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


THE PROGRAMMING PROCESS

• Programming involves four steps to develop a program:

1 2 3 4
ALGORITHM DESIGN
PROBLEM PROBLEM CODING AND
AND DATA
DEFINITION ANALYSIS DEBUGGING
REPRESENTATION

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


THE PROGRAMMING PROCESS: PROBLEM DEFINITION

• Prior to creating the computer program, one must understand the problem clearly. The
statement of the problem must show the following:

PROBLEM 1 GIVE THE


Create a program HOW DATA REQUIRED
WHAT ARE THE
WILL BE INFORMATION
that inputs three NEEDED DATA?
PROCESSED? AS A RESULT OF
numbers from a THE PROCESS
user and displays
their average. INPUT PROCESS OUTPUT
• MODULARITY IN DESIGN - It is a design principle that breaks the problem into separate tasks.

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


THE PROGRAMMING PROCESS: PROBLEM ANALYSIS

• Based on the problem defined in the previous phase, analysis will take place. The statement of
the problem helps the programmer to understand:

PROBLEM 1
Create a program WHAT DETERMINE
WHAT DATA IS
SOLUTION/S THE POSSIBLE
that inputs three GIVEN?
CAN BE DONE? PRODUCT.
numbers from a
user and displays
their average. INPUT PROCESS OUTPUT

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


THE PROGRAMMING PROCESS: PROBLEM ANALYSIS

• Based on the problem defined in the previous phase, analysis will take place. The statement of
the problem helps the programmer to understand:

PROBLEM 1
Create a program
that inputs three
numbers from a
user and displays
their average. INPUT PROCESS OUTPUT

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


THE PROGRAMMING PROCESS: PROBLEM ANALYSIS

• Based on the problem defined in the previous phase, analysis will take place. The statement of
the problem helps the programmer to understand:

PROBLEM 1
Create a program WHAT DATA IS
that inputs three GIVEN?
numbers from a
user and displays
their average. INPUT PROCESS OUTPUT

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


THE PROGRAMMING PROCESS: PROBLEM ANALYSIS

• Based on the problem defined in the previous phase, analysis will take place. The statement of
the problem helps the programmer to understand:

PROBLEM 1
Create a program
THREE NUMBERS
that inputs three
numbers from a
user and displays
their average. INPUT PROCESS OUTPUT

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


THE PROGRAMMING PROCESS: PROBLEM ANALYSIS

• Based on the problem defined in the previous phase, analysis will take place. The statement of
the problem helps the programmer to understand:

PROBLEM 1
Create a program WHAT
THREE NUMBERS SOLUTION/S
that inputs three
CAN BE DONE?
numbers from a
user and displays
their average. INPUT PROCESS OUTPUT

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


THE PROGRAMMING PROCESS: PROBLEM ANALYSIS

• Based on the problem defined in the previous phase, analysis will take place. The statement of
the problem helps the programmer to understand:

PROBLEM 1 GET THE SUM BY


ADDING THE THREE
Create a program NUMBERS
THREE NUMBERS
that inputs three GET THE AVERAGE BY

numbers from a DIVIDING THE SUM OF


THREE NUMBERS BY 3
user and displays
their average. INPUT PROCESS OUTPUT

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


THE PROGRAMMING PROCESS: PROBLEM ANALYSIS

• Based on the problem defined in the previous phase, analysis will take place. The statement of
the problem helps the programmer to understand:

PROBLEM 1 GET THE SUM BY


ADDING THE THREE
Create a program NUMBERS
DETERMINE
THREE NUMBERS THE POSSIBLE
that inputs three GET THE AVERAGE BY
PRODUCT.
numbers from a DIVIDING THE SUM OF
THREE NUMBERS BY 3
user and displays
their average. INPUT PROCESS OUTPUT

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


THE PROGRAMMING PROCESS: PROBLEM ANALYSIS

• Based on the problem defined in the previous phase, analysis will take place. The statement of
the problem helps the programmer to understand:

PROBLEM 1 GET THE SUM BY


ADDING THE THREE
Create a program NUMBERS
THREE NUMBERS DISPLAY AVERAGE
that inputs three GET THE AVERAGE BY

numbers from a DIVIDING THE SUM OF


THREE NUMBERS BY 3
user and displays
their average. INPUT PROCESS OUTPUT

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


THE PROGRAMMING PROCESS: PROBLEM ANALYSIS

PROBLEM 2
Compute and Print
out the Sum,
Average and the
Product of two
numbers. INPUT PROCESS OUTPUT

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


THE PROGRAMMING PROCESS: PROBLEM ANALYSIS

PROBLEM 2
Compute and Print
TWO NUMBERS
out the Sum,
Average and the
Product of two
numbers. INPUT PROCESS OUTPUT

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


THE PROGRAMMING PROCESS: PROBLEM ANALYSIS

PROBLEM 2 GET THE SUM BY ADDING


THE TWO NUMBERS

Compute and Print GET THE AVERAGE BY


DIVIDING THE SUM OF
TWO NUMBERS
out the Sum, TWO NUMBERS BY 2

GET THE PRODUCT BY


Average and the MULTIPLYING THE TWO
NUMBERS
Product of two
numbers. INPUT PROCESS OUTPUT

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


THE PROGRAMMING PROCESS: PROBLEM ANALYSIS

PROBLEM 2 GET THE SUM BY ADDING


THE TWO NUMBERS

Compute and Print GET THE AVERAGE BY


DIVIDING THE SUM OF
PRINT SUM,
TWO NUMBERS AVERAGE ,
out the Sum, TWO NUMBERS BY 2
PRODUCT
GET THE PRODUCT BY
Average and the MULTIPLYING THE TWO
NUMBERS
Product of two
numbers. INPUT PROCESS OUTPUT

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


THE PROGRAMMING PROCESS: PROBLEM ANALYSIS

PROBLEM 3
Write a program that
asks the user to enter
a number and
determines the result,
indicating whether
the number is
Positive, Negative, or
Zero.
INPUT PROCESS OUTPUT

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


THE PROGRAMMING PROCESS: PROBLEM ANALYSIS

PROBLEM 3
Write a program that
asks the user to enter
a number and A NUMBER

determines the result,


indicating whether
the number is
Positive, Negative, or
Zero.
INPUT PROCESS OUTPUT

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


THE PROGRAMMING PROCESS: PROBLEM ANALYSIS

PROBLEM 3 IF THE NUMBER IS GREATER


Write a program that THAN 0, DISPLAY RESULT AS
“POSITIVE”
asks the user to enter IF THE NUMBER IS LESS

a number and A NUMBER THAN 0, DISPLAY RESULT AS


“NEGATIVE”
determines the result, IF THE NUMBER IS EQUAL TO
0, DISPLAY RESULAT AS
indicating whether “ZERO”

the number is
Positive, Negative, or
Zero.
INPUT PROCESS OUTPUT

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


THE PROGRAMMING PROCESS: PROBLEM ANALYSIS

PROBLEM 3 IF THE NUMBER IS GREATER


Write a program that THAN 0, DISPLAY RESULT AS
“POSITIVE”
asks the user to enter IF THE NUMBER IS LESS
a number and A NUMBER THAN 0, DISPLAY RESULT AS
“NEGATIVE”
DISPLAY RESULT

determines the result, IF THE NUMBER IS EQUAL TO

indicating whether 0, DISPLAY RESULT AS


“ZERO”
the number is
Positive, Negative, or
Zero.
INPUT PROCESS OUTPUT

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


THE PROGRAMMING PROCESS: ALGORITHM DESIGN AND DATA REPRESENTATION

• The analyzed problem from previous phase may be represented either of the following data
representation:

ALGORITHM FLOWCHART PSEUDOCODE

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


THE PROGRAMMING PROCESS: CODING AND DEBUGGING

• CODING - It is the act of writing or creating the computer program or source code based on
the algorithm design and representation using the chosen programming language.

• Most of the time, after the computer programmer has written the source code, there are still
errors or bugs that needs fixing.

• DEBUGGING - This refers to the process of fixing bugs or errors in a computer program.
TYPES OF ERRORS

RUN-TIME ERROR SYNTAX ERROR LOGIC ERROR

• It occurs during program execution • It is an error in the structure or spelling of • Unexpected/ unintentional errors resulted
• it is detected by a compiler a statement detected by a compiler from flaw in the program’s logic.
• It occurs because of logic error or during compilation of the program. • Produce undesired result or output,
memory leak • Cannot be detected by compiler
EXAMPLE: Missing semicolon, quote, etc. • Compare the result with manual process.

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

ASSIGNMENT NO. 01
1 WHOLE SHEET OF WHITE PAPER

1. Demonstrate the Problem Analysis phase for the problem below by identifying the input,
process, and output:

Write a program that asks the user to enter two numbers and determines the result,
indicating which number is larger between the two.

INPUT PROCESS OUTPUT


2. Identify the differences between an algorithm, a flowchart, and pseudocode.

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: ALGORITHM

• ALGORITHM – is a well-defined, step-by-step procedure or set of rules for solving a problem or


performing a task.

• It is a finite list of well-defined instructions for accomplishing task.

• It always starts with Start/Begin and ends with Stop/End.

STEP 1 Start

STEP 2 procedure or set of rules

STEP 3 procedure or set of rules

STEP N Stop

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: ALGORITHM

STEP 1 Start

STEP 2 Input first number

PROBLEM 1 STEP 3 Input second number

Create a program
STEP 4 Input third number
that inputs three
numbers from a STEP 5
Add the first number, the second number, and the third number, and assign the result to
sum using the formula: sum = first number + second number + third number
user and displays Divide the sum by 3 and assign the result to average using the formula:
STEP 6
their average. average = sum / 3

STEP 7 Display average

STEP 8 Stop

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: ALGORITHM

STEP 1 Start

STEP 2 Input first number

PROBLEM 2 STEP 3 Input second number

Compute and Print Add the first number and the second number, and assign the result to sum using the
STEP 4
out the Sum, formula: sum = first number + second number

Average and the STEP 5


Divide the sum by 2 and assign the result to average using the formula:
average = sum / 2
Product of two Multiply the first number by the second number and assign the result to product using
STEP 6
numbers. the formula: product = first number * second number

STEP 7 Print sum, average, product

STEP 8 Stop

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: ALGORITHM

STEP 1 Start
PROBLEM 3
Write a program that STEP 2 Input number

asks the user to enter Determine the result of whether the number is positive, negative or zero by checking
a number and the following:
STEP 3 If number > 0, display the result as “positive”
determines the result, If number < 0, display the result as “negative”
indicating whether If number = 0, display the result as “zero”
the number is
STEP 4 Display result
Positive, Negative, or
Zero.
STEP 5 Stop

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: FLOWCHART

• FLOWCHART – It is a visual representation used to design and document the logic of a


process or algorithm. It uses standardized symbols to depict the sequence of steps, decisions,
and operations involved in solving a problem or performing a task.

• Flowcharts help programmers and analysts understand, communicate, and analyze the logic
and flow of a program before actual coding begin.

• Key components of a flowchart are as follows:

TERMINAL PROCESSING
ON-PAGE OFF-PAGE
DECISION
CONNECTOR CONNECTOR
PREPARATION DATA

FLOWLINE
Presentation by Jerico D. Quinzon
BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: FLOWCHART

• TERMINAL SYMBOL – It indicated the beginning/ starting or ending/ stopping point of the
flowchart.

START BEGIN

STOP END

NOTE: You can only have one(1) begin/start and one(1) end/stop for your flowchart

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: FLOWCHART

• PREPARATION SYMBOL – It is used to initialize the value of the variables to be used in the
flowchart.

sum = 0 length = 0

age = 18 pi = 3.1416

NOTE: Variable names are used to hold values.

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: FLOWCHART

• DATA SYMBOL – It is used for accepting data input or displaying the output.

INPUT INPUT
first number age

OUTPUT OUTPUT
sum area

NOTE: You should indicate whether the data symbol is used for INPUT and if it is used for
OUTPUT.

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: FLOWCHART

• PROCESSING SYMBOL – It is used to do action or process the data.

sum = n1 + n2 area = l * w

product = num1 * average = sum /


num2 7

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: FLOWCHART

• DECISION SYMBOL – It is used for conditional statements when operation requires more than
one answer.

• It uses relational operators like < , > , <= , >= , == , !=.

• There are two arrow heads going out from this symbol, either Yes/ True and No/ False.

T Y
grade >= 75 age != 18

F N

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: FLOWCHART

• ON-PAGE CONNECTOR SYMBOL – It is used to continue the flowchart within the same page.

A
PAGE 1

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: FLOWCHART

• OFF-PAGE CONNECTOR SYMBOL – It is used to continue the flowchart on another page.

A
PAGE 1 PAGE 2

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: FLOWCHART

• FLOWLINE SYMBOL – It shows the process’ order of operation.

• It is a line coming from one symbol and pointing to another.

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: FLOWCHART

PROBLEM 1
Create a program that inputs three numbers from a user and displays their average.
ALGORITHM FLOWCHART

Presentation by Jerico D. Quinzon


STEP 1 Start

STEP 2 Input first umber

STEP 3 Input second number

STEP 4 Input third number

Add the first number, the second number, and the third number, and assign the result to sum
STEP 5 using the formula: sum = first number + second number + third number

Divide the sum by 3 and assign the result to average using the formula:
STEP 6 average = sum / 3

STEP 7 Display average

STEP 8 Stop
START

INPUT
first number

INPUT
second number

INPUT
third number

sum = first number + second


number + third number

average = sum / 3

OUTPUT
average

STOP
BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: FLOWCHART

PROBLEM 2
Compute and Print out the Sum, Average and the Product of two numbers.
ALGORITHM FLOWCHART

Presentation by Jerico D. Quinzon


STEP 1 Start

STEP 2 Input first number

STEP 3 Input second number

Add the first number and the second number, and assign the result to sum using the formula:
STEP 4 sum = first number + second number

Divide the sum by 2 and assign the result to average using the formula:
STEP 5 average = sum / 2

Multiply the first number by the second number and assign the result to product using the
STEP 6 formula: product = first number * second number

STEP 7 Print Sum, Average, Product

STEP 8 Stop
START A

INPUT
average = sum / 2
first number

INPUT product = first number *


second number second number

OUTPUT
sum = first number + second
sum, average,
number
product

A STOP
BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: FLOWCHART

PROBLEM 3
Write a program that asks the user to enter a number and determines the
result, indicating whether the number is Positive, Negative, or Zero.
ALGORITHM FLOWCHART

Presentation by Jerico D. Quinzon


STEP 1 Start

STEP 2 Input number

Determine the result of whether the number is positive, negative or zero by checking the
following:
STEP 3 If number > 0, display the result as “positive”
If number < 0, display the result as “negative”
If number = 0, display the result as “zero”

STEP 4 Display result

STEP 5 Stop
START A B

INPUT
number T OUTPUT
number
<0 “Negative”

number T OUTPUT
>0 “Positive” T
number OUTPUT
== 0 “Zero”

F
F

A B STOP
BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: PSEUDOCODE

• PSEUDOCODE – It is a way of planning out algorithms and programs using informal, human-
readable language that resembles programming logic. It is not meant to be executed by a
computer instead it serves as a bridge between the problem description and actual code.

ALGORITHM PSEUDOCODE PROGRAM

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: PSEUDOCODE

• The first thing we do when designing a pseudocode is to decide on a name for the program.

• Let’s say we want to write a pseudocode to calculate interest, a good name for the
pseudocode would be CalculateInterest.

• Note the use of CamelCase.

• So, we start the pseudocode as:

START CalculateInterest

• Below is the format for starting and ending the pseudocode:


START <ProgramName>
<Statement>
<Statement>
STOP
Presentation by Jerico D. Quinzon
BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: PSEUDOCODE

CONTROL STRUCTURE: SEQUENCE

• SEQUENCE – Instructions are designed to be executed in the order they are written. Ist is used
to show a single action, or one action followed in order sequentially by another. Actions can be
inputs, processes, of outputs.

• In Pseudocode, a sequence looks like this:

START <ProgramName>
<Statement1>
<Statement2>
<Statement3>
<Statement4>
<Statement5>
<StatementN>
STOP
Presentation by Jerico D. Quinzon
BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: PSEUDOCODE

CONTROL STRUCTURE: SEQUENCE

• For example, for ordering a pizza:

START OrderingPizza
Go to the phone
Dial the pizza place
Order the pizza
Hang up the phone
STOP

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: PSEUDOCODE

CONTROL STRUCTURE: SELECTION

• SELECTION – The program branches off to different instructions depending on whether a


condition is met or one of several blocks of program code is executed based on a test for some
condition. It is used to tell the program which action to take, based on a certain condition.

• In Pseudocode, a selection looks like this:

START <ProgramName>
IF (<condition>)
THEN <statement1>
ELSEIF (<condition>)
THEN <statement1>
ELSE <statement>
ENDIF
STOP
Presentation by Jerico D. Quinzon
BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: PSEUDOCODE

CONTROL STRUCTURE: SELECTION

• For example, for ordering a pizza:

START OrderingPizza
IF (you have money)
THEN go to the phone
dial the pizza place
order the pizza
hang up the phone
ELSE do not order
ENDIF
STOP

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: PSEUDOCODE

CONTROL STRUCTURE: ITERATION

• ITERATION – The program repeats the same instructions over and over. It is used when a set
of actions is to be performed repeatedly.

START <ProgramName>
DO <statement>
WHILE (<condition>)
STOP

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: PSEUDOCODE

CONTROL STRUCTURE: ITERATION

• For example, for eating pizza:

START EatingPizza
DO eat pizza
WHILE (there is still pizza)
STOP

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: PSEUDOCODE

• In writing pseudocode, we use keywords.

• KEYWORDS – These are specific terms or phrases used to represent fundamental operations
and control structures that guide the logic of the algorithm.

• They are not part of any specific programming language but are used to describe the logic in
a clear and structured manner.

• These keywords help to outline the steps of an algorithm in a way that is easy to understand
and translate into actual code later.

• In pseudocode, these keywords are used to indicate common input-output and processing
operations, and they are written fully in UPPERCASE.

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: PSEUDOCODE
ACTION KEYWORDS DESCRIPTION
Start/ Begin START , BEGIN The start/ begin of your pseudocode
Retrieves a data from the user through typing or through an input
Input READ , OBTAIN, GET
device
Output PRINT , DISPLAY , SHOW Shows your output to a screen or the relevant output device
Compute COMPUTE , CALCULATE , DETERMINE Calculates the result of an expression
Initialize INIT , SET Initializes a value
Add one INCREMENT , BUMP Increases the value of a variable by 1
Minus one DECREMENT Decreases the value of a variable by 1
Stop/ End STOP , END The stop/ end of your pseudocode
Used for conditional statements to execute different block of
Selection IF , THEN , ELSE , ELSEIF , ENDIF
statements based on conditions
Used for loops to repeat a block of statements multiple times based
Iteration WHILE , DO , FOR , REPEAT , ENDWHILE
on a condition or a set number of iterations
Function FUNCTION , PROCEDURE Defines a reusable block of pseudocode
Return value RETURN Used to return a value from a function or procedure
Call function CALL Invokes a function or procedure
Presentation by Jerico D. Quinzon
BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: PSEUDOCODE

PROBLEM 1
Create a program that inputs three numbers from a user and displays their average.
ALGORITHM FLOWCHART

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: PSEUDOCODE

PROBLEM 1
Create a program that inputs three numbers from a user and displays their average.
pseudocode

START DisplayAverage
SET sum = 0
SET average = 0
READ firstNumber
READ secondNumber
READ thirdNumber
CALCULATE sum = firstNumber + secondNumber + thirdNumber
CALCULATE average = sum / 3
DISPLAY average
STOP

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: PSEUDOCODE

PROBLEM 2
Compute and Print out the Sum, Average and the Product of two numbers.
ALGORITHM FLOWCHART

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: PSEUDOCODE

PROBLEM 2
Compute and Print out the Sum, Average and the Product of two numbers.
pseudocode

START SumAverageProduct
INIT sum = 0
INIT average = 0
INIT product = 0
OBTAIN num1
OBTAIN num2
DETERMINE sum = num1 + num2
DETERMINE average = sum / 2
DETERMINE product = num1 * num2
PRINT sum, average, product
STOP
Presentation by Jerico D. Quinzon
BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: PSEUDOCODE

PROBLEM 3
Write a program that asks the user to enter a number and determines the
result, indicating whether the number is Positive, Negative, or Zero.
ALGORITHM FLOWCHART

Presentation by Jerico D. Quinzon


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY (BSINFOTECH)

BASIC PROGRAMMING CONCEPTS


ALGORITHM DESIGN AND DATA REPRESENTATION: PSEUDOCODE

PROBLEM 3
Write a program that asks the user to enter a number and determines the
result, indicating whether the number is Positive, Negative, or Zero.
pseudocode

START PositiveNegativeZero
READ num
IF (num > 0)
THEN DISPLAY num + “is positive”
ELSEIF (num < 0)
THEN DISPLAY num + “is negative”
ELSE DISPLAY num + “is zero”
ENDIF
STOP

Presentation by Jerico D. Quinzon

You might also like