Flowchart & Pseudocode
Through this journey we will be learning problem solving approaches, skills and their associated tools. If we have given any problem what we'll do first? we first understand the problem and its context and then we try to think of the solution and write down the steps of solution and then we try to convert our solution(idea) into the code.
So for writing down the solution we will use flow chart and pseudocode.
Flowchart
- It is a visual representation of the solution to a given problem.
- It allows us to see the solution step by step by breaking them into smaller steps.
Flowchart Components
- Start: The starting point of the flowchart. similarly
End
is the end point where the flowchart ends. - Input/Output: The input and output of the flowchart.
- Process: The process of the flowchart.
- Decision: The decision of the flowchart.
- Arrow: The arrow that connects the process to the decision.
Lets understand the flowchart by looking at the following flowchart. img img
Decision Making
Decision making is a process of making a choice based on the available options. we have decision box, it kind of looks like a kite shape.
so lets see an example:
- check whether number is Odd or even
- Find largest of three numbers
Understanding Loops
So let suppose we have to print numbers from 1 to n. then how do we do it? Obivously we will start from 1 and then after priting 1 we have to think the next number of the sequence, so we'll basically add 1 in the previous number and we'll get the next number, this process will keep repeating until we reach n. and when we reach n then we have to check that we don't write the number which comes after the n. Here you will see you are repeating the process and a loop is formed.
eg:
- find if a given number is prime or not.
- find the prime numbers till N.
Let's solve a problem.
// find largest of N numbers
10, 8, 15, 6, 20