DFC1023
PROBLEM SOLVING & PROGRAM DESIGN
C H A P T E R 3 :
FUNDAMENTALS OF PROGRAMMING
LANGUAGE
S U B T O P I C 3 . 3 :
PROGRAM CONTROL STRUCTURES
AT THE END OF THIS CHAPTER, STUDENTS SHOULD BE ABLE
TO:
Apply program control structure
1.Control structure in problem solving :
 Sequence
 Selection
 Repetition
1.Illustrate flow of control structure using pseudo
code and flow chart.
2.Write pseudo code and flow chart using control
structure.
3. Design the algorithm for a given case study.
PROGRAM CONTROL STRUCTURE
In 1966, two researchers, C. Bohn and G.Jacopini,
demonstrated that any algorithm can be described using
only 3 control structures:
1. Sequence control structure
2. Selection/decision control structure
1. If……endif
2. If……else
3. Nested if
3. Looping control structure
1. For
2. While
3. Do……while
SEQUENCE CONTROL STRUCTURE
• In this control, every step will be executed one by
one from top to bottom.
• Every box in control structure is a process. Every
process is done sequentially.
• The beginning and end of a block of statements
can be optionally marked with the keywords
begin/start and end.
SEQUENCE CONTROL STRUCTURE
Format:
Pseudocode:
Start
Statement A;
Statement B;
End
Flowchart:
Start
Statement A
Statement B
End
SEQUENCE CONTROL STRUCTURE
PROBLEM:
Compute the total overtime wages of an employee.
 Problem Analysis:
 Input:
Hours, Basic_salary, OT_rate
 Process:
1) calculate overtime using formula:
Overtime = OT_rate * Hours
2) calculate salary using formula:
Salary = Basic_salary + Overtime
 Output:
Salary
SEQUENCE CONTROL STRUCTURE
 Algorithm:
1. Enter Hours, Basic_salary, OT_rate
2. Calculate overtime using formula:
Overtime = OT rate * Hours
3. Calculate salary using formula:
Salary = Basic_salary + Overtime
4. Display Salary
 Pseudocode:
Start
Input Hours, Basic_salary, OT_rate;
Overtime = OT_rate * Hours;
Salary = Basic_salary + Overtime;
Display Salary;
End
SEQUENCE CONTROL STRUCTURE
 Flowchart START
Input Hours,
Basic_salary, OT_rate
Overtime = OT_rate * Hours
Output Salary
END
Salary = Basic_salary + Overtime
SELECTION / DECISION CONTROL
STRUCTURE
 Usually used in structured programming.
 Control structure will execute an instruction based on result
of a condition or comparison, the result either TRUE or
FALSE.
 If the condition result is true, the control program will
execute the instruction within the TRUE loop operation.
 Otherwise, it will execute the next instruction or the
instruction within the FALSE loop operation.
SELECTION / DECISION CONTROL
STRUCTURE
Type of selection / decision control
structure:
1. If……endif
2. If……else
3. Nested if
SELECTION / DECISION CONTROL
STRUCTURE
1. If……endif
Rules:
If (condition)
Instruction (do this instruction if
condition is true)
Endif
If condition is not true, no instruction will
be executed
SELECTION / DECISION CONTROL
STRUCTURE
Pseudocode:
If (condition)
True statement
Endif
START
Condition Statement
END
False
True
• Flowchart
SELECTION / DECISION CONTROL
STRUCTURE
Problem
If student’s grade is greater than or equal to
60
Print “Passed”
Pseudocode:
if ( grade >= 60 )
print “ Passed”
endif
SELECTION / DECISION CONTROL
STRUCTURE
Flowchart
SELECTION / DECISION CONTROL
STRUCTURE
2) IF…….Else
• Rules:
If (condition)
True statement
Else
False statement
Endif
SELECTION / DECISION CONTROL
STRUCTURE
 Pseudocode:
If (condition)
True statement
Else
False statement
Endif
 Flowchart
START
Condition
END
False True
Statement 2 Statement 1
SELECTION / DECISION CONTROL
STRUCTURE
Problem
If student’s grade is greater than or equal to 60
Print “Passed” else Print “Failed”
 Pseudocode:
if ( grade >= 60 )
print “ Passed”
else
print “ Failed”
endif
SELECTION / DECISION CONTROL
STRUCTURE
 Flowchart
SELECTION / DECISION CONTROL
STRUCTURE
3. NESTED IF
 There are 3 types:
Type 1:
If (condition1)
If (condition2)
If (condition3)
True statement
Endif
Endif
Endif
SELECTION / DECISION CONTROL
STRUCTURE
• Type 2:
If (condition1)
If (condition2)
If (condition3)
Statement that will be executed if condition1,
condition2 and condition3 are true
Else
Statement that will be executed if condition1,
and condition2 are true but condition3 is false
Endif
Else
Statement that will be executed if condition1 is
true but condition2 and condition3 is false
Endif
Else
Statement that will be executed if condition1 is
false
Endif
SELECTION / DECISION CONTROL
STRUCTURE
• Type 3:
If (condition1)
Statement that will be executed if condition 1 is true
Else
If (condition 2)
Statement that will be executed if condition2 is true but condition1 is
false
Else
If (condition3)
Statement that will be executed if condition3 is true but
condition1 and condition2 are false
Else
Statement that will be executed if condition1, condition2 and
condition3 are false
Endif
Endif
SELECTION / DECISION CONTROL
STRUCTURE
Problem
 Pseudo code
If (grade >=90)
Print “A”
Else If (grade >=80)
Print “B”
Else If (grade >=70)
Print “C”
Else If (grade >=60)
Print “D”
Else
Print “F”
REPETITION CONTROL STRUCTURE
Problem : Develop a program to print “FP101 is easy” for 5
times without looping.
Solution:
Understand the problem: repeat print “DFC1023 is easy” 5
times.
1. Problem Analysis:
 Input : None
 Proses : None
 Output : print “DFC1023 is easy” for 5 times
REPETITION CONTROL STRUCTURE
2. Algorithm:
1. print “DFC1023 is easy” for 5
times.
3. Pseudocode:
START
print “DFC1023 is easy” for 5
times;
END
4. Flow Chart
Print “DFC1023 is easy”
Print “DFC1023 is easy”
Print “DFC1023 is easy”
Print “DFC1023 is easy”
Print “DFC1023 is easy”
START
END
3 BASIC TYPES OF REPETITION
CONTROL:
•From one number to
another number and
increases/decrease
by a specified value
each time
for loop
•The while loop can
be used if we don’t
know how many
times a loop must
run.
while loop
•DO..WHILE loops are
useful for things that
want to repeat at
least once.
do …
while loop
do
{
do repeat statement
} while ( condition );
while ( condition )
{
Process repeat
while the condition
is true
}
for ( variable initialization;
end condition; variable
update )
{
Repeat statement
process
}
FLOW CHART
while
is
i < 10?
print i
i = i+1
is
i < 10?
print i
i = i+1
do-while
i++
i < 10?Print i
i = 0
End
No
Yes
For
Yes
Yes
No
No
3 basic types of Repetition Control:
Start
End
Start
End
Start
i = 0 i = 0
CASE STUDY
 Problem : Develop a program can print
“DFC1023 is easy” for 5 times using
looping.
 Solution:
 Understand the problem:
 repeat print “DFC1023 is easy” 5 times .
1.SOLUTION USING FOR CONTROL LOOP
1. Problem Analysis:
Input:
None
Process:
print “FP 101 is easy”
repeat until the condition
(5 times) to exit the loop is
met
Output:
print “FP101 is easy”
2. Algorithm:
1. Set n = 0
2. Check condition (n < 5)
If true,
print “FP101 is easy”.
Go to step 3.
If false, process will end.
3. Increase counter using
formula :
n = n + 1
Go to step 2.
1. SOLUTION USING FOR CONTROL LOOP
3. Pseudo code:
Start
For (n=0; n<5; n++)
{
print “DFC1023 is easy”;
}
End
4. Flow Chart
n++
n< 5?Print “DFC1023 is
easy”
n = 0
End
Start
No
Yes
2.SOLUTION USING WHILE CONTROL LOOP
1. Problem Analysis:
Input:
None
Process:
print “DFC1023 is easy”
repeat until the condition
(5 times) to exit the loop is
met
Output:
print “FP101 is easy”
2. Algorithm:
1. Set n=0
2. Check condition (n < 5)
If true,
print “DFC1023 is easy”.
Go to step 3.
If false, process will end.
3. Increase counter using
formula :
n = n+1
Go to step 2.
2. SOLUTION USING WHILE CONTROL LOOP
3. Pseudo code:
Start
Set n = 0;
While (n < 5)
{
print “DFC1023 is easy”;
n++;
}
End while
End
4. Flow Chart
is
n < 5?
print “DFC1023 is easy”
n = n+1
Yes
No
End
Start
n = 0
3. SOLUTION USING DO…WHILE CONTROL
LOOP
1. Problem Analysis:
Input:
None
Process:
print “DFC1023 is easy”
repeat until the condition
(5 times) to exit the loop is
met
Output:
print “FP101 is easy”
2. Algorithm:
1. Set n = 0
2. Print “DFC1023 is easy”.
3. Increase counter using
formula :
n = n+1
4.Check condition (n < 5)
If true, Go to step 2.
If false, process will end.
3. SOLUTION USING DO…WHILE CONTROL
LOOP
3. Pseudo code:
Start
Set n = 0;
Do
{
print “DFC1023 is easy”;
n++;
} While (n < 5)
End
4. Flow Chart
End
Start
is
n < 5?
print “DFC1023 is
easy”
Yes
No
n = n+1
n = 0
POLITEKNIK MALAYSIA

More Related Content

PPT
3 definition of operating systems
PPTX
Introduction to programming
PDF
Introduction to ICS 1st Year Book
PPT
Basic Troubleshooting
PPTX
Troubleshooting
PPT
Protecting Your Child Online
DOCX
CLASS VIII COMPUTERS FLOW CHART AND ALGORITHM
PPTX
Health and safety requirements for computer maintenance
3 definition of operating systems
Introduction to programming
Introduction to ICS 1st Year Book
Basic Troubleshooting
Troubleshooting
Protecting Your Child Online
CLASS VIII COMPUTERS FLOW CHART AND ALGORITHM
Health and safety requirements for computer maintenance

What's hot (20)

PPTX
An introduction to Windows 10
PPTX
Interaction styles
PPTX
Unified process model
PDF
Bringing Mickey's 10 commandments Online
PPTX
Programming Language
PDF
Hci activity#2
PPT
Basic mouse and_keyboarding_pp
PPTX
Computer fundamentals
PPTX
COMPONENTS OF COMPUTER SYSTEM.pptx
PPTX
Materials and tools used for making Ethernet cables
PPTX
Pseudocode
PPT
Software development slides
DOCX
Csc 102 lecture note(introduction to problem solving)
PPT
User Interface
PPTX
Open source software and os
PPT
Lecture6
PPTX
Coc 1 basic computer parts
PPT
Program design and problem solving techniques
PPT
شرح مقرر البرمجة 2 لغة جافا - الوحدة الاولى
PPTX
Troubleshooting and maintenance
An introduction to Windows 10
Interaction styles
Unified process model
Bringing Mickey's 10 commandments Online
Programming Language
Hci activity#2
Basic mouse and_keyboarding_pp
Computer fundamentals
COMPONENTS OF COMPUTER SYSTEM.pptx
Materials and tools used for making Ethernet cables
Pseudocode
Software development slides
Csc 102 lecture note(introduction to problem solving)
User Interface
Open source software and os
Lecture6
Coc 1 basic computer parts
Program design and problem solving techniques
شرح مقرر البرمجة 2 لغة جافا - الوحدة الاولى
Troubleshooting and maintenance
Ad

Similar to POLITEKNIK MALAYSIA (20)

PPT
Visula C# Programming Lecture 3
PPTX
BLM101_2.pptx
PPTX
Python for Beginners(v2)
PDF
Lecture 6.1 flow control selection
PPTX
Introduction to flowchart
PDF
VB PPT by ADI PART3.pdf
PDF
VB PPT by ADI PART3.pdf
PDF
Introductiontoflowchart 110630082600-phpapp01
PPT
Flow of control c++
PDF
Loop and while Loop
PPT
PPT
Python Control structures
PPT
Control statments in c
PPTX
control statements of clangauge (ii unit)
PPT
Structured Program Development in C Language
PPT
C_chap03 study of c++ lecture structured program.ppt
PDF
LEC 5 [CS 101] Introduction to computer science.pdf
PPTX
CSC116-Topic6Decision .pptx
PPT
Pengenalan kepada pengaturcaraan berstruktur
PDF
Conditional Statements
Visula C# Programming Lecture 3
BLM101_2.pptx
Python for Beginners(v2)
Lecture 6.1 flow control selection
Introduction to flowchart
VB PPT by ADI PART3.pdf
VB PPT by ADI PART3.pdf
Introductiontoflowchart 110630082600-phpapp01
Flow of control c++
Loop and while Loop
Python Control structures
Control statments in c
control statements of clangauge (ii unit)
Structured Program Development in C Language
C_chap03 study of c++ lecture structured program.ppt
LEC 5 [CS 101] Introduction to computer science.pdf
CSC116-Topic6Decision .pptx
Pengenalan kepada pengaturcaraan berstruktur
Conditional Statements
Ad

More from Aiman Hud (20)

PDF
POLITEKNIK MALAYSIA
PDF
POLITEKNIK MALAYSIA
PDF
POLITEKNIK MALAYSIA
PDF
POLITEKNIK MALAYSIA
PDF
POLITEKNIK MALAYSIA
PPT
POLITEKNIK MALAYSIA
PPTX
POLITEKNIK MALAYSIA
PPT
POLITEKNIK MALAYSIA
PPT
POLITEKNIK MALAYSIA
PPT
POLITEKNIK MALAYSIA
PPTX
POLITEKNIK MALAYSIA
PPT
POLITEKNIK MALAYSIA
PDF
POLITEKNIK MALAYSIA
PPT
POLITEKNIK MALAYSIA
PPTX
POLITEKNIK MALAYSIA
PPTX
POLITEKNIK MALAYSIA
PPTX
POLITEKNIK MALAYSIA
PPTX
POLITEKNIK MALAYSIA
PPT
POLITEKNIK MALAYSIA
PPT
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA

Recently uploaded (20)

PDF
Top 10 Project Management Software for Small Teams in 2025.pdf
PPTX
Comprehensive Guide to Digital Image Processing Concepts and Applications
PPTX
ROI from Efficient Content & Campaign Management in the Digital Media Industry
PPTX
Chapter 1 - Transaction Processing and Mgt.pptx
PPTX
HackYourBrain__UtrechtJUG__11092025.pptx
PPTX
Bandicam Screen Recorder 8.2.1 Build 2529 Crack
PPTX
StacksandQueuesCLASS 12 COMPUTER SCIENCE.pptx
PPT
3.Software Design for software engineering
PPTX
Foundations of Marketo Engage: Nurturing
PDF
solman-7.0-ehp1-sp21-incident-management
PDF
Cloud Native Aachen Meetup - Aug 21, 2025
PPTX
MCP empowers AI Agents from Zero to Production
PPTX
Folder Lock 10.1.9 Crack With Serial Key
PDF
Streamlining Project Management in Microsoft Project, Planner, and Teams with...
PPTX
FLIGHT TICKET API | API INTEGRATION PLATFORM
PDF
Engineering Document Management System (EDMS)
PDF
SOFTWARE ENGINEERING Software Engineering (3rd Edition) by K.K. Aggarwal & Yo...
PPTX
Presentation - Summer Internship at Samatrix.io_template_2.pptx
PPTX
Swiggy API Scraping A Comprehensive Guide on Data Sets and Applications.pptx
PDF
Coding with GPT-5- What’s New in GPT 5 That Benefits Developers.pdf
Top 10 Project Management Software for Small Teams in 2025.pdf
Comprehensive Guide to Digital Image Processing Concepts and Applications
ROI from Efficient Content & Campaign Management in the Digital Media Industry
Chapter 1 - Transaction Processing and Mgt.pptx
HackYourBrain__UtrechtJUG__11092025.pptx
Bandicam Screen Recorder 8.2.1 Build 2529 Crack
StacksandQueuesCLASS 12 COMPUTER SCIENCE.pptx
3.Software Design for software engineering
Foundations of Marketo Engage: Nurturing
solman-7.0-ehp1-sp21-incident-management
Cloud Native Aachen Meetup - Aug 21, 2025
MCP empowers AI Agents from Zero to Production
Folder Lock 10.1.9 Crack With Serial Key
Streamlining Project Management in Microsoft Project, Planner, and Teams with...
FLIGHT TICKET API | API INTEGRATION PLATFORM
Engineering Document Management System (EDMS)
SOFTWARE ENGINEERING Software Engineering (3rd Edition) by K.K. Aggarwal & Yo...
Presentation - Summer Internship at Samatrix.io_template_2.pptx
Swiggy API Scraping A Comprehensive Guide on Data Sets and Applications.pptx
Coding with GPT-5- What’s New in GPT 5 That Benefits Developers.pdf

POLITEKNIK MALAYSIA

  • 1. DFC1023 PROBLEM SOLVING & PROGRAM DESIGN C H A P T E R 3 : FUNDAMENTALS OF PROGRAMMING LANGUAGE S U B T O P I C 3 . 3 : PROGRAM CONTROL STRUCTURES
  • 2. AT THE END OF THIS CHAPTER, STUDENTS SHOULD BE ABLE TO: Apply program control structure 1.Control structure in problem solving :  Sequence  Selection  Repetition 1.Illustrate flow of control structure using pseudo code and flow chart. 2.Write pseudo code and flow chart using control structure. 3. Design the algorithm for a given case study.
  • 3. PROGRAM CONTROL STRUCTURE In 1966, two researchers, C. Bohn and G.Jacopini, demonstrated that any algorithm can be described using only 3 control structures: 1. Sequence control structure 2. Selection/decision control structure 1. If……endif 2. If……else 3. Nested if 3. Looping control structure 1. For 2. While 3. Do……while
  • 4. SEQUENCE CONTROL STRUCTURE • In this control, every step will be executed one by one from top to bottom. • Every box in control structure is a process. Every process is done sequentially. • The beginning and end of a block of statements can be optionally marked with the keywords begin/start and end.
  • 5. SEQUENCE CONTROL STRUCTURE Format: Pseudocode: Start Statement A; Statement B; End Flowchart: Start Statement A Statement B End
  • 6. SEQUENCE CONTROL STRUCTURE PROBLEM: Compute the total overtime wages of an employee.  Problem Analysis:  Input: Hours, Basic_salary, OT_rate  Process: 1) calculate overtime using formula: Overtime = OT_rate * Hours 2) calculate salary using formula: Salary = Basic_salary + Overtime  Output: Salary
  • 7. SEQUENCE CONTROL STRUCTURE  Algorithm: 1. Enter Hours, Basic_salary, OT_rate 2. Calculate overtime using formula: Overtime = OT rate * Hours 3. Calculate salary using formula: Salary = Basic_salary + Overtime 4. Display Salary  Pseudocode: Start Input Hours, Basic_salary, OT_rate; Overtime = OT_rate * Hours; Salary = Basic_salary + Overtime; Display Salary; End
  • 8. SEQUENCE CONTROL STRUCTURE  Flowchart START Input Hours, Basic_salary, OT_rate Overtime = OT_rate * Hours Output Salary END Salary = Basic_salary + Overtime
  • 9. SELECTION / DECISION CONTROL STRUCTURE  Usually used in structured programming.  Control structure will execute an instruction based on result of a condition or comparison, the result either TRUE or FALSE.  If the condition result is true, the control program will execute the instruction within the TRUE loop operation.  Otherwise, it will execute the next instruction or the instruction within the FALSE loop operation.
  • 10. SELECTION / DECISION CONTROL STRUCTURE Type of selection / decision control structure: 1. If……endif 2. If……else 3. Nested if
  • 11. SELECTION / DECISION CONTROL STRUCTURE 1. If……endif Rules: If (condition) Instruction (do this instruction if condition is true) Endif If condition is not true, no instruction will be executed
  • 12. SELECTION / DECISION CONTROL STRUCTURE Pseudocode: If (condition) True statement Endif START Condition Statement END False True • Flowchart
  • 13. SELECTION / DECISION CONTROL STRUCTURE Problem If student’s grade is greater than or equal to 60 Print “Passed” Pseudocode: if ( grade >= 60 ) print “ Passed” endif
  • 14. SELECTION / DECISION CONTROL STRUCTURE Flowchart
  • 15. SELECTION / DECISION CONTROL STRUCTURE 2) IF…….Else • Rules: If (condition) True statement Else False statement Endif
  • 16. SELECTION / DECISION CONTROL STRUCTURE  Pseudocode: If (condition) True statement Else False statement Endif  Flowchart START Condition END False True Statement 2 Statement 1
  • 17. SELECTION / DECISION CONTROL STRUCTURE Problem If student’s grade is greater than or equal to 60 Print “Passed” else Print “Failed”  Pseudocode: if ( grade >= 60 ) print “ Passed” else print “ Failed” endif
  • 18. SELECTION / DECISION CONTROL STRUCTURE  Flowchart
  • 19. SELECTION / DECISION CONTROL STRUCTURE 3. NESTED IF  There are 3 types: Type 1: If (condition1) If (condition2) If (condition3) True statement Endif Endif Endif
  • 20. SELECTION / DECISION CONTROL STRUCTURE • Type 2: If (condition1) If (condition2) If (condition3) Statement that will be executed if condition1, condition2 and condition3 are true Else Statement that will be executed if condition1, and condition2 are true but condition3 is false Endif Else Statement that will be executed if condition1 is true but condition2 and condition3 is false Endif Else Statement that will be executed if condition1 is false Endif
  • 21. SELECTION / DECISION CONTROL STRUCTURE • Type 3: If (condition1) Statement that will be executed if condition 1 is true Else If (condition 2) Statement that will be executed if condition2 is true but condition1 is false Else If (condition3) Statement that will be executed if condition3 is true but condition1 and condition2 are false Else Statement that will be executed if condition1, condition2 and condition3 are false Endif Endif
  • 22. SELECTION / DECISION CONTROL STRUCTURE Problem  Pseudo code If (grade >=90) Print “A” Else If (grade >=80) Print “B” Else If (grade >=70) Print “C” Else If (grade >=60) Print “D” Else Print “F”
  • 23. REPETITION CONTROL STRUCTURE Problem : Develop a program to print “FP101 is easy” for 5 times without looping. Solution: Understand the problem: repeat print “DFC1023 is easy” 5 times. 1. Problem Analysis:  Input : None  Proses : None  Output : print “DFC1023 is easy” for 5 times
  • 24. REPETITION CONTROL STRUCTURE 2. Algorithm: 1. print “DFC1023 is easy” for 5 times. 3. Pseudocode: START print “DFC1023 is easy” for 5 times; END 4. Flow Chart Print “DFC1023 is easy” Print “DFC1023 is easy” Print “DFC1023 is easy” Print “DFC1023 is easy” Print “DFC1023 is easy” START END
  • 25. 3 BASIC TYPES OF REPETITION CONTROL: •From one number to another number and increases/decrease by a specified value each time for loop •The while loop can be used if we don’t know how many times a loop must run. while loop •DO..WHILE loops are useful for things that want to repeat at least once. do … while loop do { do repeat statement } while ( condition ); while ( condition ) { Process repeat while the condition is true } for ( variable initialization; end condition; variable update ) { Repeat statement process }
  • 26. FLOW CHART while is i < 10? print i i = i+1 is i < 10? print i i = i+1 do-while i++ i < 10?Print i i = 0 End No Yes For Yes Yes No No 3 basic types of Repetition Control: Start End Start End Start i = 0 i = 0
  • 27. CASE STUDY  Problem : Develop a program can print “DFC1023 is easy” for 5 times using looping.  Solution:  Understand the problem:  repeat print “DFC1023 is easy” 5 times .
  • 28. 1.SOLUTION USING FOR CONTROL LOOP 1. Problem Analysis: Input: None Process: print “FP 101 is easy” repeat until the condition (5 times) to exit the loop is met Output: print “FP101 is easy” 2. Algorithm: 1. Set n = 0 2. Check condition (n < 5) If true, print “FP101 is easy”. Go to step 3. If false, process will end. 3. Increase counter using formula : n = n + 1 Go to step 2.
  • 29. 1. SOLUTION USING FOR CONTROL LOOP 3. Pseudo code: Start For (n=0; n<5; n++) { print “DFC1023 is easy”; } End 4. Flow Chart n++ n< 5?Print “DFC1023 is easy” n = 0 End Start No Yes
  • 30. 2.SOLUTION USING WHILE CONTROL LOOP 1. Problem Analysis: Input: None Process: print “DFC1023 is easy” repeat until the condition (5 times) to exit the loop is met Output: print “FP101 is easy” 2. Algorithm: 1. Set n=0 2. Check condition (n < 5) If true, print “DFC1023 is easy”. Go to step 3. If false, process will end. 3. Increase counter using formula : n = n+1 Go to step 2.
  • 31. 2. SOLUTION USING WHILE CONTROL LOOP 3. Pseudo code: Start Set n = 0; While (n < 5) { print “DFC1023 is easy”; n++; } End while End 4. Flow Chart is n < 5? print “DFC1023 is easy” n = n+1 Yes No End Start n = 0
  • 32. 3. SOLUTION USING DO…WHILE CONTROL LOOP 1. Problem Analysis: Input: None Process: print “DFC1023 is easy” repeat until the condition (5 times) to exit the loop is met Output: print “FP101 is easy” 2. Algorithm: 1. Set n = 0 2. Print “DFC1023 is easy”. 3. Increase counter using formula : n = n+1 4.Check condition (n < 5) If true, Go to step 2. If false, process will end.
  • 33. 3. SOLUTION USING DO…WHILE CONTROL LOOP 3. Pseudo code: Start Set n = 0; Do { print “DFC1023 is easy”; n++; } While (n < 5) End 4. Flow Chart End Start is n < 5? print “DFC1023 is easy” Yes No n = n+1 n = 0