Selection and Iteration Symbols in Raptor and their usage
Activity Outcomes:
This lab teaches you the following topics:
At the end of this lab student will know how to develop logic of a program
Students will get clear understanding of two important Problem-Solving techniques which are:
o Selection
o Iteration or Looping
Introduction
Selection
Selection means selecting a set of statements for execution under a certain condition, the condition should a logical test involving logical and relational operators.
For example:
display A/B only when B is not equal to zero, means we have to test B for the specific value of zero.
Raptor uses the symbol
for selection type statements .
Diamond Symbol
The diamond symbol represents the logical test.
YES branch means execution path when condition evaluates to be true.
NO side branch represents execution path when the condition evaluates to be false.
Iteration or Looping
Iteration means repetition i.e. to repeat a set of statements a certain number of times or to repeat the statements until a specific condition is met.
For example:
if the user enters a negative value for his age then ask him to enter the age repeatedly until he enters a value greater than zero.
Raptor uses the symbol
for looping.
Lab Activities:
Activity 1:
Draw a flowchart that tells user whether the Integer entered is Even or Odd Number, use % symbol to test the remainder value.
Solution:
Activity 2:
Draw a flowchart to accept two values from user and display the larger one.
Solution:
Activity 3:
Draw a flowchart for a program that reads two numbers and displays the number series from first to last number.
Solution:
Home Activities:
1. Draw a flow chart to calculate the Sum of series from Starting to Ending Number, the increment per cycle is also entered by the user.
2. Construct flow chart to Calculate Factorial of a Number entered by the user.