C Prog Govt Poly Unit 1 Algorithm&Flowchart
C Prog Govt Poly Unit 1 Algorithm&Flowchart
CS/IT
Unit 1- Introduction to C Programming
Prof. Akhil M. Jaiswal
9028637523
Fundamentals Of Algorithms:
Define Algorithm:
Algorithm is “A step by step logic used to solve some specific problem for a defining a
program”. Therefore Algorithm refers to a set of rules/instructions that step-by-step define
how a work is to be executed upon in order to get the expected results.
Advantages of Algorithms:
It is easy to Understand, Write & Debug.
Algorithm is a step-wise representation of a solution to a given problem.
In Algorithm the problem is broken down into smaller pieces or steps hence, it is easier for
the programmer to convert it into an actual program.
Disadvantages of Algorithms:
1. Define the Problem: First the problem must be defined in clear words that need to be solved.
2. Identifying Inputs: The Data inputs required to solve the problem must be identified & defined.
3. Identifying Outputs: The Expected Result from the algorithm must be Identified & specified.
4. Identifying Steps: The set of all steps required to process the input & generate expected output
must be defined & each step in the algorithm should be carried out easily.
Example of Algorithms:
1) Algorithm to calculate square of a given number.
Algorithm: Square
Input: A Number
Step 1: Start
Step 6: Stop
Flowchart: The Flowchart is the graphical representation of an algorithm. It uses various symbols
to show the operations and decisions to be followed in a program. In other words, It’s the pictorial
representation drawn for logic display before the program to be written.
Examples of flowcharts:
2. Find the largest among three different numbers entered by the user.
Declare Variables
NUM & SQUARE
STOP
Declare Variables
RADIUS & AREA
STOP
Declare Variables
NUM1 & NUM2
If NUM1 >NUM2
STOP