Flow of the Program
Last updated
Last updated
A flow chart is a visualization of the thought process or algorithm, represented diagrammatically. It uses various symbols to depict different elements in the flow of a program:
Start / Stop: Oval shape indicating the starting and ending points of the flow chart.
Input / Output: Parallelogram used to represent input and output.
Processing: Rectangle used to represent processes such as mathematical computations or variable assignments.
Condition: Diamond shape used to represent conditional statements resulting in true or false (Yes or No).
Flow Direction: Arrow shape used to represent the flow of the program.
Example 1:
Task: Take a name and output "Hello, name."
Flow Chart:
Example 2:
Task: Take input of a salary. If the salary is greater than 10,000
, add a bonus of 2000
; otherwise, add a bonus of 1000
.
Flow Chart:
Example 3:
Task: Input a number and print whether it is prime or not.
Flow Chart:
Pseudocode is a rough code representing how the algorithm of a program works. It does not require syntax and provides a high-level understanding of the logic.
To optimize the prime solution, we can utilize the fact that we only need to check factors up to the square root of the number being tested. This significantly reduces the number of iterations required.
This optimized approach minimizes the number of iterations needed to determine whether a number is prime.