Problem Sloving Flowchart, Logic Diagram Psedu Code
Problem Sloving Flowchart, Logic Diagram Psedu Code
Outline
• Information Processing Cycles
• Problem Solving
• Problem
• Logic Building
• Structure theorem
• Pseudo codes
• Flowcharts
2
Information Processing Cycle
• A computer is a machine that, under a program’s direction and control, perfroms
four basic operations:
• Input
• Processing
• Output
• Storage
• A program is a sequence of instructions that tells
the computer how to perform these four operations
in order to accomplish a task.
3
st
1 Basic Operation : Input
• When a computer is required to take an input from a particular source, whether
it is a terminal, a disk or any other device, the verbs Read and Get are used.
• Example :
• You are writing an essay in MS word
• Computer reads/gets 2 values to add them up
4
nd
2 Basic Operation : Output
• When a computer is required to provide output to a device, the verbs
Print, Write, Output, or Display are used in pseudo code.
• Usually an output Prompt instruction is required before an input Get
instruction.
• Example :
• You are viewing and printing your essay
• Computer displays / writes the added result of 2 values
5
rd
3 Basic Operation : Processing
• Arithmetic Operations:
• Mathematical calculation, Formula, and for these, a programmer uses either
actual mathematical symbols or the words for those symbols.
• Comparison or Logical Operations:
• A computer can compare two variables and select one or two alternate
actions
• Example:
X = 5, Y = 7 X > Y OR X < Y
Z=X+Y
Z=5+7
Z = 12
6
th
4 Basic Operation : Storage
• An information is stored in some location in memory called Variable.
• 3 situations when need to store a value to a variable or memory
location:
• To give data an initial value in pseudo code, the verbs Initialize or Set are used
• To assign a value as a result of some processing the symbols '=' or ‘ ' are
written
• To keep a variable for later use, the verbs Save or Store are used
• Example:
• You are downloading a song in your laptop
• Z = X + Y or Z X + Y
7
Problem to Solve
What steps would you propose to solve the following problem?
Your hair are dirty/greasy and want to clean up
8
Problem to Solve
• Problem:
Algorithm
Hair are dirty
• Turn on water tab
• Solution:
• Wet you hair
Wash the hair
• Apply shampoo
• How:
• Leather
Wash the hair Algorithm
• Rinse hair
• Dry off
9
Steps in Problem Solving (in computer
programming)
10
Steps in Problem Solving
• First produce a general algorithm (one can use pseudocode)
11
Pseudocode & Algorithm
• Example 1: Write an algorithm to determine a student’s final grade
and indicate whether it is passing or failing. The final grade is
calculated as the average of four marks.
12
Pseudocode
Pseudocode:
• Input a set of 4 marks
• Calculate their average by summing and dividing by 4
• if average is below 50
Print “FAIL”
else
Print “PASS”
13
Algorithm
• Detailed Algorithm
• Step 1: Input M1,M2,M3,M4
Step 2: GRADE ← (M1+M2+M3+M4)/4
Step 3: if (GRADE < 50) then
Print “FAIL”
else
Print “PASS”
endif
14
Characteristics of Algorithm
• Definite and having Input and Output
• Well-ordered
• The steps are in a clear order
• Unambiguous
• The operations described are understood by a computing agent without
further simplification.
• Effectively Computable
• The computing agent can actually carry out the operation
• Algorithms can be executed by a computing agent which is not
necessarily a computer
15
Rules of Algorithm
• For Input:
Use keyword “Input” or “Get” followed by a list of variables separated by a single
comma.
Example
Input a
Input a , b Good Practice:
Get a Show a message
Get a,b before to prompt user
for input.
• For Output:
Use keyword “Output”, “Display” or “Print” followed by a variable name or text. Enclose
“text/message” in inverted commas. Do not enclose variable name in inverted commas.
Example
Output “Enter a number”
16
Display “Your number is ” num
Rules of Algorithm
• Storage/ Assignment
Use the keyword “Set” in combination with “=” or “:=” OR use keyword “=”, “:=” or “<-”
Example
Set X=8
X=8 Good Practice:
Set X:=8 • Number your steps.
X:= 8 • Indicate Start and End
X<- 8 of the Algorithm.
17
Addition of Two Numbers
• Input: number1 and number2
• Output: Sum of number1 and number2
• Steps:
1. Start
2. Input number1 , number2
3. Sum = number1 + number2
4. Display Sum
5. End
18
Flow Chart
19
Quick Recap
• Pseudo-code
• High level description of algorithm…
• intended for human reading
• but structured like a programming language
20
Pseudo code & Flowchart
• There are two commonly used tools to help to build logic (algorithm).
• Pseudo code is an artificial and informal language that helps programmers
develop algorithms.
• Pseudo code may be an informal English, combinations of computer languages and
spoken language. Whatever works for you.
• A Flowchart is another algorithm but graphical that shows logic solution.
• Emphasizes individual steps and their interconnections.
• A flowchart must have a start and stop.
• A step in a flowchart must connect i.e. You can’t leave a step “hanging” with no
connection. e.g. control flows from one action to the next
21
What is flow chart?
• The flowchart is one of the most basic methods of representing
algorithms. It is useful as a precise method of explanation in some
circumstances.
• A flowchart is a diagrammatic\pictorial representation of the
operations involved in a data processing system.
22
Flow chart Symbols
• Start/End
• Used at the beginning and end of each flowchart.
• Input/Output
• Shows when information/data comes into a program or is printed out.
• Process
• Used to show calculations, storing of data in variables, and other “processes”
that take place within a program.
23
Flow chart Symbols
N Y
• Decision X>7?
• Used to show that the program must decide whether something (usually a
comparison between numbers) is true or false. YES and NO (or T/F) branches
are usually shown.
• Connector
• Used to show that flowchart continues on another page.
• Flow Direction
• Show you how you have to move
24
Example
Algorithm START
• Step 3: Print A
A←LxW
Output
W, L
STOP
25
Example
START
Input M1,M2,M3,M4
GRADE ← (M1+M2+M3+M4)/4
Input
M1,M2,M3,M4
if (GRADE <50) then
Print “FAIL”
else
GRADE←(M1+M2+M3+M4)/4 Print “PASS”
endif
N IS Y
GRADE<5
0
Print Print
“PASS” “FAIL”
STOP
26
Example
Flowchart
Algorithm
• Step 1: Input Left START
Output
Lcm
STOP
27
Trace Table
28
Trace Tables & Dry Run
• Algorithm
• A sequence of steps designed to perform a particular task
• Dry run
• Working through a section of a program manually
• Trace table
• A table constructed with a column to identify the instruction executed and columns
for the contents of each variable
• Variable
• The identifier associated with a particular memory location used to store data
• Constant
• A data item with a fixed value
29
Example 1
• Algorithm – Trace table A - indicates Nil
1. Start
– Let user Input for y s 5
2. Set x := 0
3. input y Step Algorithm Lines X Y Output
4. x := y * 2
5. Output x 1 Start - - -
6. End 2 Set x := 0 0 - -
3 input y 0 5 -
4 x := y * 2 10 5 -
5 Output x 10
6 End - - -
30
Example 2
– Algorithm : Take five inputs from user, calculate and display their sum and average
(Without using loop)
1. Start
2. input : num1, num2, num3, num4 and num5
3. Set sum := 0 , average := 0 , totalNumbers :=5
4. input in num1, num2, num3, num4 and num5
5. sum := num1 + num2 + num3 + num4 + num5
6. average := sum / totalNumbers
7. Print “Sum is ” sum
8. Print “Average is ” average
9. End
31
– Trace table: Take five inputs from user, calculate and display their sum and
average (Without using loop)
Example 2 – Assume input: 25, 17, 34, 9, 75
# Algorithm Lines num1 num2 num3 num4 num5 sum average totalNu Output
mbers
1 Start - - - - - - - - -
2 input : num1, num2, num3, num4 and - - - - - - - - -
num5
3 Set sum := 0 , average := 0 , - - - - - 0 0 5 -
totalNumbers :=5
4 input num1, num2, num3, num4 and 25 17 34 9 75 0 0 5 -
num5
5 sum := num1 + num2 + num3 + num4 + 25 17 34 9 75 0 0 5 -
num5
6 average := sum / totalNumbers 25 17 34 9 75 160 32 5 -
7 Print “Sum is ” sum 25 17 34 9 75 160 32 5 Sum is 160
8 Print “Average is ” average 25 17 34 9 75 160 32 5 Sum is 160
Average is 32
9 End - - - - - - - - -
32
Example 3
– Algorithm : Take five inputs from user, calculate 10. Input num
and display their sum and average (Without
11. sum := sum + num
using loop)
1. Start 12. Input num
2. Num=0 13. sum := sum + num
3. Set sum := 0 , average := 0 , totalNumbers :=5 14. average := sum / totalNumbers
4. Input num 15. Print “Sum is ” sum
5. sum := sum + num
16. Print “Average is ” average
6. Input num
17. End
7. sum := sum + num
8. Input num
9. sum := sum + num
33
– Take five inputs from user using only 1 variable for input, calculate and display
their sum and average (Without using loop)
Example 3 – Assume input: 25, 17, 34, 9, 75
1 Start - - - - -
2 num=0 0 - - - -
3 Set sum := 0 , average := 0 , totalNumbers :=5 - 0 0 5 -
4 Input num 25 0 0 5 -
5 sum := sum + num 25 25 0 5 -
6 input num 17 25 0 5 -
7 sum := sum + num 17 42 0 5 -
8 Input num 34 42 0 5 -
9 sum := sum + num 34 76 0 5 -
10 input num 9 76 0 5 -
11 sum := sum + num 9 85 0 5 -
34
– Take five inputs from user using only 1 variable for input, calculate and display
their sum and average (Without using loop)
Example 3 – Assume input: 25, 17, 34, 9, 75
12 Input num 75 85 0 5 -
13 sum := sum + num 75 160 0 5 -
14 average := sum / totalNumbers 75 160 32 5 -
15 Print “Sum is ” sum 75 160 32 5 Sum is 160
16 Print “Average is ” average 75 160 32 5 Sum is 160
Average is 32
17 End - - - - -
35
– Algorithm : Take five inputs from user using only 1 variable
Example 4 for input, calculate and display their totalSum, sumOfEven
and average (Without using loop)
36
– Algorithm : Take five inputs from user using only 1 variable for input, calculate and
display their totalSum, sumOfEven and average (Without using loop)
# Algorithm Lines num1 num2 num3 num4 num5 sum sumOfEven average totalNumb
ers
1 Start - - - - - - - - -
2 Set num1=0, num2=0, num3=0, num4=0, 0 0 0 0 0 - - - -
num5=0
3 Set sum := 0 , sumOfEven := 0, average - - - - - 0 0 0 5
:= 0 , totalNumbers := 5
4 input in num1, num2, num3, num4 and 24 19 34 18 75 0 0 0 5
num5
5 sum := num1 + num2 + num3 + num4 + 24 19 34 18 75 0 0 0 5
num5
6 average := sum / totalNumbers 24 19 34 18 75 170 0 34 5
7 If (num1 mod 2 = 0 ) 24 19 34 18 75 170 0 34 5
8 Then sumOfEven := sumOfEven +num1 24 19 34 18 75 170 24 34 5
9 End if 24 19 34 18 75 170 24 34 5
37
– Algorithm : Take five inputs from user using only 1 variable for input, calculate and
display their totalSum, sumOfEven and average (Without using loop)
# Algorithm Lines num1 num2 num3 num4 num5 sum sumOfEven average totalNumb
ers
10 If (num2 mod 2 = 0 ) 24 19 34 18 75 170 24 34 5
11 Then sumOfEven := sumOfEven +num2 24 19 34 18 75 170 24 34 5
12 End if 24 19 34 18 75 170 24 34 5
13 If (num3 mod 2 = 0 ) 24 19 34 18 75 170 24 34 5
14 Then sumOfEven := sumOfEven +num3 24 19 34 18 75 170 58 34 5
15 End if 24 19 34 18 75 170 58 34 5
16 If (num4 mod 2 = 0 ) 24 19 34 18 75 170 58 34 5
17 Then sumOfEven := sumOfEven +num4 24 19 34 18 75 170 76 34 5
18 End if 24 19 34 18 75 170 76 34 5
19 If (num5 mod 2 = 0 ) 24 19 34 18 75 170 76 34 5
20 Then sumOfEven := sumOfEven +num5 24 19 34 18 75 170 76 34 5
21 End if 24 19 34 18 75 170 76 34 5
38
– Algorithm : Take five inputs from user using only 1 variable for input, calculate and
display their totalSum, sumOfEven and average (Without using loop)
# Algorithm Lines num1 num2 num3 num4 num5 sum sumOfEven average totalNumb
ers
22 Print “ Total Sum is ” sum 24 19 34 18 75 170 76 34 5
23 Print “Average is ” average 24 19 34 18 75 170 76 34 5
24 Print “ Sum of evens is ” sum 24 19 34 18 75 170 76 34 5
25 End - - - - - - - - -
Output
22 Total Sum is 170
23 Total Sum is 170
Average is 34
24 Total Sum is 170
Average is 34
Sum of evens is 76
39
Take five inputs from user, calculate and display their
Example 5 sum and average (With using loop)
– Algorithm:
1. Start
2. Num=0
3. Set sum := 0 , average := 0 , totalNumbers := 5, loopCounter := 1
4. Repeat while (loopCounter <= totalNumbers)
5. Begin
6. input num
7. display “Enter input ” loop counter “:”
8. sum := sum + num
9. loopCounter = loopCounter + 1
10. End while
11. average := sum / totalNumbers
12. Print “Total Sum is ” sum
13. Print “Average is ” average
40
13. End
Take five inputs from user, calculate and display their sum
and average (With using loop)
Example 5 – Assume input: 25, 17, 34, 9, 75
# Algorithm Loop Pass / num sum average totalNumbers loopCounter loopCounter <= totalNumbers
Step Iteration
1 1 - - - - - - -
2 2 - 0 - - - - -
3 3 - - 0 0 5 1 -
4 4 - - 0 0 5 1 True
5 5 1 - 0 0 5 1 True
6 6 1 25 0 0 5 1 True
7 7 1 25 25 0 5 1 True
8 8 1 25 25 0 5 2 True
9 Repeat ----- go to step 4
9 4 - 25 25 0 5 2 True
10 5 2 25 25 0 5 2 True
41
# Algorithm Loop Pass / num sum average totalNumbers loopCounter loopCounter <= totalNumbers
Step Iteration
11 6 2 17 25 0 5 2 True
12 7 2 17 42 0 5 2 True
13 8 2 17 42 0 5 3 True
9 Repeat ----- go to step 4
14 4 - 17 42 0 5 3 True
15 5 3 17 42 0 5 3 True
16 6 3 34 42 0 5 3 True
17 7 3 34 76 0 5 3 True
18 8 2 34 76 0 5 4 True
9 Repeat ----- go to step 4
19 4 - 34 76 0 5 4 True
20 5 4 34 76 0 5 4 True
21 6 4 9 76 0 5 4 True
22 7 4 9 85 0 5 4 True
23 8 4 9 85 0 5 5 True
42
# Algorithm Loop Pass / num sum average totalNumbers loopCounter loopCounter <= totalNumbers
Step Iteration
9 Repeat ----- go to step 4
24 4 - 9 85 0 5 5 True
25 5 5 9 85 0 5 5 True
26 6 5 75 85 0 5 5 True
27 7 5 75 160 0 5 5 True
28 8 5 75 160 0 5 6 True
9 Repeat ----- go to step 4
29 4 - 75 160 0 5 6 False
Loop ended --- go to step 10
30 10 - 75 160 32 5 6 -
31 11 - 75 160 32 5 6 -
32 12 - 75 160 32 5 6 -
33 13 - - - - - - -
43
Step Output for total algorithm
6 Enter input 1: 25
6 Enter input 2: 17
6 Enter input 3: 34
6 Enter input 4: 9
6 Enter input 5: 75
11 Total Sum is 160
12 Total Sum is 160
Average is 32
44
Take five inputs from user, calculate and display their
Example 5.1 sum and average (With using loop)
# Algorithm Loop Pass / num sum average totalNumbers loopCounter loopCounter <= totalNumbers
Step Iteration
1 1 - - - - - - -
2 2 - 0 - - - - -
3 3 - - 0 0 5 0 -
4 4 - - 0 0 5 0 True
5 5 1 - 0 0 5 0 True
6 6 1 - 0 0 5 1 True
7 7 1 25 0 0 5 1 True
8 8 1 25 25 0 5 1 True
9 Repeat ----- go to step 4
9 4 - 25 25 0 5 1 True
10 5 2 25 25 0 5 1 True
46
# Algorithm Loop Pass / num sum average totalNumbers loopCounter loopCounter <= totalNumbers
Step Iteration
11 6 2 25 25 0 5 2 True
12 7 2 17 25 0 5 2 True
13 8 2 17 42 0 5 2 True
9 Repeat ----- go to step 4
14 4 - 17 42 0 5 2 True
15 5 3 17 42 0 5 2 True
16 6 3 17 42 0 5 3 True
17 7 3 34 42 0 5 3 True
18 8 2 34 76 0 5 3 True
9 Repeat ----- go to step 4
19 4 - 34 76 0 5 3 True
20 5 4 34 76 0 5 3 True
21 6 4 34 76 0 5 4 True
22 7 4 9 76 0 5 4 True
23 8 4 9 85 0 5 4 True
47
# Algorithm Loop Pass / num sum average totalNumbers loopCounter loopCounter <= totalNumbers
Step Iteration
9 Repeat ----- go to step 4
24 4 - 9 85 0 5 4 True
25 5 5 9 85 0 5 4 True
26 6 5 9 85 0 5 5 True
27 7 5 75 85 0 5 5 True
28 8 5 75 160 0 5 5 True
9 Repeat ----- go to step 4
29 4 - 75 160 0 5 5 False
Loop ended --- go to step 10
30 10 - 75 160 32 5 5 -
31 11 - 75 160 32 5 5 -
32 12 - 75 160 32 5 -
33 13 - - - - - - -
48
Step Output for total algorithm
6 Enter input 1: 25
6 Enter input 2: 17
6 Enter input 3: 34
6 Enter input 4: 9
6 Enter input 5: 75
11 Total Sum is 160
12 Total Sum is 160
Average is 32
49
Summary
• In this lecture, we have covered:
• Algorithm creation
• Trace table and dry run
50
Problem Solving
Structure Theorem
Tools and techniques for solving a problem
51
What is the Structure theorem
• It states that it is possible to write any algorithm by using only three
basic control structures.
• Sequence
• I have to study classes from grade 1 to grade 8.
• I cannot skip any class in order to reach in grade 8.
• Repetition
• If I am fail in a grade I have to repeat it until pass.
• Selection
• I have passed my 8th grade, now I have to select between Science and Arts groups.
52
Decision/ Selection
• Sometimes we need to put certain condition before performing some
action, then action will depend upon the condition if its fulfilled or not
Selection statements help us to get this thing done
• This construct represents the decision making abilities of the computer to
compare two pieces of information and select one of two alternative
actions.
• In pseudocode, selection is represented by the keywords IF, THEN, ELSE
and ENDIF
• An IF statement always has a condition to check, often a comparison between a
variable and a number.
• The IF statement also must specify what to do if the condition/comparison is true.
• These instructions (for “true”) may come after the word THEN, or they may simply
be listed.
53
Types of Selection
• IF – THEN – ENDIF(Single IF)
• Single IF selection statement either performs (selects) an action if a condition is true
or skips the action if the condition is false.
• IF – ELSE – ENDIF (Double IF)
• The IF-ELSE selection statement performs an action if a condition is true and
performs a different action if the condition is false
• IF – ELSE IF – ELSE – ENDIF (Multiple IF)
• The IF – ELSE IF – ELSE selection statement performs one of many different actions,
depending on the value of an expression.
• Switch (Alternate to Multiple IF)
• The SWITCH selection statement performs one of many different actions,
depending on the value of an expression.
54
Rules for Selection statement
• One Option
IF (condition) then
<<steps>>
Endif
• Two Options
IF(condition) then
<<steps>>
Else
<<steps>>
Endif
• Multiple Conditions
IF (condition) then 55
Decision/ Selection
Problem: Input the marks of the students and display pass if the marks are
50 else display fail.
Start
Step 1: Input Marks
Step 2: IF Marks > 50 THEN
Step 3: Display “Pass”
Step 4: ELSE
Step 5: Display “Fail”
Step 6: ENDIF
Step 7: End
56
Repetition
• A loop is a repetition of all or part of the commands in a program.
• A loop often has a counter (a variable) and continues to repeat a
specified number of times.
• A loop may also continue till than a condition is true or until a certain
condition is met (e.g., until the end of a file or until a number reaches
a set limit)
• Example
• WHILE condition p is true
• Statement(s) to execute
• ENDWHILE
57
Types of Repetition
• WHILE
• while loop is a control flow statement that allows code to be executed
repeatedly based on a given boolean condition. The while loop can be
thought of as a repeating if statement.
• DO WHILE
• The DO WHILE statement performs the action (or group of actions) in its body
at least once.
• FOR
• The FOR loop allows code to be repeatedly executed.
• For loops are also typically used when the number of iterations is known
before entering the loop.
58
While Loop
• The while loop is used to repeat a section of code an unknown
number of times until a specific condition is met.
• While loops execute blocks of code over and over again.
• The advantage to a while loop is that it will go (repeat) as often as
necessary to accomplish its goal.
• Algorithm rules:
while ( condition )
<<steps>>
end while
• The "something" should eventually result
in the condition being false
59
Example: While Loop
while (condition)
action
• How it works:
• if condition is true then execute action
• repeat this process until condition evaluates to false
• action is either a single statement or a group of statements.
• Example
while (number<10)
Display “Hello number ” number “player”
Number=Number +1
End while
60
Do While Loop
• The DO WHILE statement performs the action (or group of actions) in
its body at least once.
Do
<<steps>>
While (condition)
• Example
number =1
Do
Display “Hello number ” number “player” 61
For Loop
• A for loop is classified as an iteration statement.
• Unlike many other kinds of loops, such as the while loop, the for loop
is often distinguished by an explicit loop counter or loop variable.
• This allows the body of the for loop to know about the sequencing of
each iteration.
• For loops are also typically used when the number of iterations is
known before entering the loop.
• For loops are the shorthand way to make loops when the number of
iterations is known, as a for loop can be written as a while loop.
62
Example
• RULES
For (initialize; condition; change)
<<steps>>
End for
• Example
For (number=1; number<10;number++)
Display “Hello number ” number “player”
End for 63
For Vs. While
• For loop is used when you know the number of iterations you have to
make, mean when you know how many times to execute a loop.
• WHILE is used when you are not sure about the iterations but you
know what the condition is and then you can loop that till the
condition is met.
• But both can be used in both situations
64
Repetition
• Pretest loop: evaluation occurs before the statements within the loop are processed
• Posttest loop: evaluation occurs after the statements within the loop are processed
• The step at which the loop starts is called its "entrance"
• The last step performed before completion is called its "exit".
• The conditional test that controls the exit from a loop should be placed either
immediately following the entrance to the loop or following all steps in its body, but never
in the middle of the body.
• Loops with tests at entrance are said to pretest i.e while-do.
• Loops with tests after entire body are said to posttest i.e do-while.
• It is imperative that at least one statement within the statement block alter the condition
and eventually render it false, otherwise the logic may result in an endless loop.
65
Repetition
• Example
Set student_total to 0
WHILE student_total < 10
Read student record
Print student name and address
Add 1 to student_total
ENDWHILE
• The variable student total is initialized before the loop condition is
executed. The student total variable is incremented within the body
of the loop so it will eventually stop.
66
Modules
• Modules break an algorithm into logical parts (like your groups)
• Helps with Clarity and Understandability
• Modules can be reused
• Within the same algorithm
• In a different algorithm
• In Programming Modules can be called:
• Sub-routines (in older languages)
• Functions (in procedural languages like C/C++)
• Methods(in object oriented languages like Java)
67
Same problem can be done using for loop.
Increment statement will work as last line in the
loop.
68
Take as many inputs as user wants using -1 as sentinel
Example 6 value, calculate and display their sum and average
– Algorithm:
1. Start
2. input num=0 10. end if
3. Set sum := 0 , average := 0 , totalNumbers := 11. totalNumbers := totalNumbers +1
0, loopCounter := 0
4. Repeat while (true) 12. sum := sum + num
11. end if
69
Example 6: Trace table
Step Output for total algorithm
Enter input 1: 25
Enter input 2: 17
Enter input 3: 34
Enter input 4: 9
Enter input 5: 75
Enter input 6: -1
Total Sum is 160
Total Sum is 160
Average is 32
70
Take as many inputs as user wants using -1 as sentinel value,
Example 7 calculate and display sumOfEvens and sumOfOdds
– Algorithm:
1. Start
2. num=0 10. end if
3. Set sum := 0 , average := 0 , totalNumbers := 11. if (num mod 2 = 0)
0, loopCounter := 0
4. Repeat while (true) 12. then sumOfEvens := sumOfEvens +num
72
Practice Questions
• Temperature converter
• Currency converter
• Leap Year calculator
• Grade calculator
• Number of days in a given month (if and switch)
• Alphabet character is vowel or consonant (if and switch)
73
Practice Questions
• Factorial of given number
• Prime number
• Fibonacci Series
• (Optional) Using Single * printing line, square, triangle, etc (Nested
loops)
74
Summary
• In this lecture, we have covered:
• What is Problem Solving and its Logic Building
• What is Structure theorem
• What is algorithm and how to represent
theorem
it in Pseudo codes and flow chart
75