FOP Lab (2) Examples
FOP Lab (2) Examples
Flowcharts
𝟏 𝟏 𝟏
✗ Ex1: 𝑺 = + + ⋯+
𝟐 𝟒 𝒏 START
Flowchart Input n
I2,S0
S S+1/I
I I+2
YES Is
I<=N
NO
Print S
End
Loop (Repetition): Examples
START
Flowchart
Input x, n
result x, counter 1
Is NO
counter<n
YES
Print result
result result *x
Step 1: Start
Step 2: Input N
Step 3: fact 1
Step 4: Counter 1
Step 5: if (Counter <= n) then
fact fact* counter
Counter Counter + 1
go to step 4
Step 6: Print fact
Step 7: End
Loop (Repetition): Examples
START
Flowchart
Input N
fact 1, counter 1
Is NO
counter<=n
YES
Print fact
fact fact*counter
Step 1: Start
Step 2: a 0, b 1, i 1
Step 3: print a , b
Step 4: S a+b
Step 5: print S
Step 6: a b
Step 7: b s
Step 8: i i+1
Step 9: if (i<= 50) then
go to step 3
Step 10: End
Exercises
Write an algorithm and draw a flowchart to enter a number and
displays whether the number is positive or negative .
16