Week 2part 1 DCIT22 Introduction To Program Logic Formulation and Program Coding
Week 2part 1 DCIT22 Introduction To Program Logic Formulation and Program Coding
Lesson 1:
Introduction to Program
Logic Formulation and
Program Coding
Prepared by:
Ms.Mariella R. Leyba, MIT
OBJECTIVES
After the completion of the chapter, students will be
able to:
• Assignment Operation
• Read Operation
Basic Elements of Pseudocode:
2. Assigned Operation
3. Read Operation
- intends to retrieve the value previously
assigned to that variable.
Example:
- Set the value of num1 equal to the
value of num2.
Operation:num1 = 5
num2 = 6 Pseudocode:
Step 1: Start
num1 = num2 Step 2: Assign 5 to num1.
Output: num1 = 6 Step 3: Assign 6 to num2.
Step 4: Set the value of num1 equal
num2 = 6 to the value of num2.
Step 5: End
Basic Elements of Pseudocode:
Step 1: Begin.
Step 2: Print “Enter first number:”, num1.
Step 3: Print “Enter second number:”, num2.
Step 4: Add num1 and num2 for the value of sum.
Step 5: Print “The sum is “, sum.
Step 6: Quit.
num1 = 10
Enter first number: 10
num2 = 5
Enter second number: 5
sum = num1 + num2
The sum is 15
sum= 15
EXAMPLE
S
BASIC nname = “Ella”
fnum = 10
ARITHMETIC snum = 5
difference = fnum - snum
PSEUDOCODE
- Step 1: Start
- Step 2: Print “Enter your nickname”,
nname.
- Step 3: Print “Enter first number:”,
fnum.
- Step 4: Print “Enter second number:”,
snum.
- Step 5: Subtract snum from fnum for
the value of difference.
- Step 6: Print “Good day,”, nname, “!”.
- Step 7: Print “The difference of”,
fnum, “and “, snum, “is “,
difference
DECISION fnum = 6
snum = 3
MAKING
PSEUDOCODE
- Step 1: Start
- Step 2: Print “Enter first number:”, fnum.
- Step 3: Print “Enter second number:”,
snum.
- Step 4: If fnum is greater than the value of
snum.
- Step 4.1: Print fnum, “ is greater than “,
snum.
- Step 5: Else, print snum, “ is greater than
“, fnum.
- Step 6: End
LOOPING
current_year = 2020
name = “Mariella”
birth_year = 1998
age = current_year - birth_year
PSEUDOCODE
- Step 1: Start
- Step 2: Read current_year=2020
- Step 3: Print “Enter your name:”, name
- Step 4: Print “Enter your birth year:”,
birth_year
- Step 5: The value of age is equal to
current_year minus
birth_year.
- Step 6: Print “Hi”, name, “! You are ”,
age, “ years old this year 2020.”
- Step 7: Print “Do you want to try again?
(Y or N)”, answer
- Step 8: Check if answer is equals to ‘Y’.
- Step 8.1: Then, go to Step 3.
- Step 9: Else, print “Thank you!”
Thank you and God
bless! ☺
___