Intro of Flowchart
Basically Flowchart is know as a diagram that represents an algorithm. we use flow chart for breaking down the problem for better understanding before goin to write code.
Here is some step to think about how to breakdown problem or think about problem
- Analyse your problem
- Break down problem in smaller sub parts
- Write down solution on paper
- verify your solution
- write code
So, in this tut we're going to discuss only on 1st to 4th step later we are discuss about 5th step.
Why Flowchart
we need cause after that possibility more less to get error rather than just writing code and also we can communicate with problem with help of flow chart (what dose it mean it mean we can understand more easily what's going on in problem).
Flowchart Components
- Terminators
Start : Mainly used to denote the start point of the program
End : Used to denote the end point of the program.
- Input/Output
Read var : Used for taking input from the user and store it in variable ‘var’
Print var : Used to output value stored in variable ‘var’.
- Process
Used to perform the operation(s) in the program. For example: Sum(2, 3) just performs arithmetic summation of the numbers 2 and 3.
- Decision
Used to make decision(s) in the program means it depends on some condition and answers in the form of TRUE(for yes) and FALSE(for no).
- Arrows
Generally, used to show the flow of the program from one step to another. The head of the arrow shows the next step and the tail shows the previous one.
- Connector
Used to connect different parts of the program and are used in case of break-through. Generally, used for functions(which we will study in our further sections).
Let's go through some example for more understanding
Example1 : Suppose we have to make a flowchart for adding 2 numbers.
solution :
Example2 : Suppose we have to make a flowchart of Decision making
solution :
Here leave home considered as start and reach school as end.
Now I hope you can figure out how to use decision(also called diamond shaped) making problem.
Now do some problem with pen and paper for more understanding other wish it can be you easily forget thing.
Check weather number is odd even.
Note: Operator % is used to find the remainder of a number with respect to another number. for ex : 4 % 3 = 1 or 10 % 5 = 0
Find largest of three number.
- Find sum of numbers form 1 to N.
(Hint: Think about loop rather then writing same thing) - Find largest of N numbers (just think about other then u can do google for better understating)
- Check weather number is prime or not.