Flow Chart

November 16, 2021 Posted by Pasindu Sathsara

     FLOW CHART


  • Flowcharts can be used to represent algorithms visually, they use Diagram which use particular symbols to show the flow of data, processing and input/output that takes place within a program or task.
  • The image below shows that standard flowchart symbols that we use,


WHEN TO USE A FLOWCHART


  • To develop understanding of how a process is done
  • To study a process for improvement
  • To communicate to others how a process is done
  • When better communication is needed between people involved with the same process
  • To document a process
  • When planning a project


Main Flow Chart Structurers 



  1. Sequence structure
  2. Selection structure
  3. Reptation structure 
 

Sequence Structure

A sequence structure is a simplest flowcharting construction. 

Example :-

A program is to be developed allows to user enter  two number and final output is shown to sum of these numbers. 

We can write a algorithm above question like what is given below.

Algorithm

Step 1 :- Start

Step 2:- Enter 1st number (A)

Step 3 :- Enter 2nd number (B)

Step 4 :- Sum = A+B

Step 5 :- Print Sum

Step 6 :- End

We can show that code flow chart 




Selection Structure

The selection control structure allows one of see of statement to be executed if a condition is true and another set of action to be executed if a condition  is false.  

Example :-

Think a program is to be developed allows to user enter number and check  whether  if user entered number is Even number print "This number is even number" otherwise print "This number is not even number". We have to write code that problem through selection method.  

Algorithm

Step 1 :- Start

Step 2:- Enter 1st number (A)

Step 3 :- If  A/2 %0 then

Step 4 :- print("This number is even number") 

Step 5 :- else

Step 6 :-  print("This number is not even number") 

Step 7 :- End





Reptation Structure


Repetition structures are used to repeat statements or blocks of code. The decision whether to repeat the code is based on the evaluation of a logical expression. If the expression is true, the code is executed. If false, the code is not executed

      Example :-


Write an algorithm and  flow chart using reptation structure  follow this question. Think  you have to print  0 to10 numbers so  get the right program structure using above method. 

Step 1 :- Start

Step 2:- Set C = 0

Step 3 :- If  C<=10

Step 4 :- print(C) 

Step 5 :- C = C+1

Step 6 :- Stop






Representation of algorithms

November 15, 2021 Posted by Pasindu Sathsara

 Representation of algorithms 


  • Algorithms can be designed using pseudo-code and/or Flow charts. 
  • They are written  using statements and expressions. 
  • Pseudocode is more concise and clear than structured English. 
  • Representing your problem solution with a flow chart or pseudocode allows you to concentrate on the logic.
  • The representation of an algorithm is extremally important.  
  • It must rapidly convey the algorithm's meaning with the least amount of effort by the reader. 
  • The best representation for one algorithm may be the worst for another.    
  • Algorithm are generally representation by either,          
    •  Verbal 
    • Algebraic
    • Tabular 
    • Hierarchical
    • Data Flow Diagram
    • Flow chart
    • Pseudo code   


    
 

What is an algorithm ?

November 15, 2021 Posted by Pasindu Sathsara

    What is an algorithm ?


  •  An algorithm is a set of step by step instructions for solving a problem to achieve a result.  
  • Set of rules to be followed in solving problem.
  • Algorithm is step by step procedure  which defines set of instruction to be executed in a certain order to get desired output.
  • Sequence of computational   steps that transform the input into the output. 
  • Algorithm can perform calculation, data processing and automated reasoning tasks. 
  • Algorithm can be implemented in more than one language. 
Example :-

     We can describe how to make a instant noodles ?

  • First you have to boil water an then put the noodles in boil water. 
  • Then after few miniates add ingredients and other related packets in the noodles packet. 
  • Next put that noodles to the plate and make attractive noodles dish.   
  • Then serve it. 

To make the instructions clear and ambiguous we can draw a chart the same sequence of steps in what is given below.  


 There are five main important characteristic of an algorithm as stated below. 

  • An algorithm is well ordered. 
  • An algorithm has ambiguous operations. 
  • An algorithm has effectively computable operations.
  • An algorithm produces a results. 
  • An algorithm halts in a finite amount of time.