Flowchart and algorithms in c 


An algorithm and flowchart are powerful tools for learning programming. To avoid errors in the program, every beginner is recommended to practice algorithm and flowchart before actual programming. The algorithm and flowchart are the pre-planning processes for learning programming. 

 

Algorithms in c 

 

An algorithm is the sequence of steps to solve a particular program. It is the step-wise representation of a solution to a problem, which makes it easier for a programmer to understand the program.

An algorithm consists of three characteristics:

Input: An algorithm may or may not require input.

Task: An algorithm should consist of one or more task which has to be performed.

Output: An algorithm must have at least one output.


Flowchart in c

A flowchart is the diagrammatic representation of the c program to solve a problem. A flowchart is an excellent way to connect with the logic of the program. It becomes easier for a programmer to analyze a problem using a flowchart. 

During the development of a program, a flowchart plays an important to understand the flow of a program, which makes the development process easier.

After the successful development of the program, the flowchart gives continuous support for sustaining the program. 

To draw a flowchart, we use standard symbols.

Below are the standard symbols used to represent a program.

 

Flowchart-c-programming


Oval:: Oval is used to represent the start and end of the Flowchart. The flowchart starts with   an oval symbol and ends with an oval symbol.

Parallelogram:: Parallelogram is used for the input and output purpose of the program. The input and output of a program are represented using a parallelogram symbol.

Rectangle:: Rectangle symbol is used for representing any arithmetic operations and data-operations performed in a program.

Diamond:: Diamond symbol is used to represent the decision-making operation of a program. Basically, used in the operation where there are two/three alternatives, and the decision is to be taken true or false, etc.

Arrows:: Arrows are flow lines used to indicate the flow of the logic by connecting the symbols.

Circle:: The circle is represented as a page connector. It is used in complex flowcharts, where the connection of symbols exceeds more than one page. When the flowchart is at the bottom of the page, and you want to move from one page to another, continuing the same flowchart, in such case connector helps to maintain the flow of the flowchart from one page to another.

Let us take some examples,

Example1: Algorithm and Flowchart to find the sum of two numbers.

Algorithm:

      Step 1: Start
      Step 2: Accept two numbers a and b
      Step 3: Sum=a+b
      Step 4: Display Sum
      Step 5: Stop

Flowchart:

flowchart-c-programming

Example2: Algorithm and Flowchart to find whether the number is even or odd.

Algorithm:

      Step 1: Start
      Step 2: Accept Number num
      Step 3: Check: If num%2==0 Then   
      Print: num is an even number.
      Else
      Print: num is an odd number.
      Step 4: Stop

 Flowchart:

flowchart-find-whether-number-even-or-odd

 

Example 3:: Flowchart to write the table of any number using while loop.

Algorithm:

 Step 1: Start

      Step 2: Accept Number num
      Step 3:  i=1
      Step 4: Check: while i<=10 Then   
                  num=num*i
                  Print: num
        End Loop
      Step 5: Stop

 Flowchart:



Flowchart-in-c