Function,Algorithm and Flowcharts

The function it is a named block of code that performs some specific task. It got three parts


  1. Return type
  2. function name
  3. arguments
Return type: When a function is executed it may or it may not return a result to its caller if it is not returning a result then a keyword void is used.

Function Name: Any valid name can be given.

Argument: If some value is given to the function as input they are called arguments.


Algorithm: In the most simpler way it gives a rough idea of a program by not following and programming language just simple language like English and logic of the program.

E.g. write an algorithm for a program to accept three numbers and find the largest among them
Step-1 Start
Step-2 Insert three numbers
Step-3 Accept three numbers in n1,n2,n3
Step-4 Compare n1>n2 and n1>n3
Step-5 If true display n1 is the largest
Step-6 If false compare n2>n1 and n2>n3
Step-7 If true display n2 is the largest
Step-8 If false display n3 is the largest
Step-9 Stop

Flowchart: Its a graphical representation of an algorithm

Sorry, I cannot give the notations here due to copyright stuff so please use google.

Here is an example of flowchart made using Lucidchart by myself


one correction there are arrows between accept input and r









Comments

Popular posts from this blog

C++ programming toll plaza simulation program

C++ program to give you hug(pun intended)