0% found this document useful (0 votes)
14 views8 pages

Chapter 2

Uploaded by

soullyykeos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views8 pages

Chapter 2

Uploaded by

soullyykeos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

22-23

COMPUTER STUDIES
CLASS 12TH NOTES

Chapter # 2
Algorithm and Flowcharts

Eng. Noman Khan


Cell# 0312228690
Class 12th
Prepared by : Sir Noman Khan class XII

Chapter # 2
Algorithm and Flowchart
Algorithm :
An algorithm is a finite sequence of unambiguous instruction design to solve particular
problem and instructions. In other word we can say it is a set of instruction /step / rules which are
followed to solve a problem.
Algorithms act as an exact list of instructions that conduct specified actions step by step
in either hardware- or software-based routines. Algorithms are widely used throughout all areas
of IT.
Unambiguous mean each step has an action to perform next must be uniquely determine
by the instruction and data available at that time
Advantages of Algorithms:
 It is a step-wise representation of a solution to a given problem, which makes it easy to
understand.
 An algorithm uses a definite procedure.
 It is not dependent on any programming language, so it is easy to understand for anyone
even without programming knowledge.
 Every step in an algorithm has its own logical sequence so it is easy to debug.
 By using algorithm, the problem is broken down into smaller pieces or steps hence; it is
easier for programmer to convert it into an actual program.
Example of Algorithm:
Some few example of simple algorithm
Algorithm : Sum of two number
Step 1: start
Step 2: declare a variable num 1 , num 2 and sum .
Step 3: read values num1 and num 2
Step 4: add num 1 and num2 and assign result to Sum
Sum = num1 + num2
Step 5: display result or sum
Step 6 : stop
Algorithm : average of three number
Step 1: Start
Step 2 :Read the three number suppose "a","b","c" form the user.
Step 3: Declared a variable "sum" and "Avg".
Step 4 : sum=a+b+c;
Step 5: Avg=sum/3
Step 6:Display "sum " and "Avg".
Step 7 :End .

Page 2
Prepared by : Sir Noman Khan class XII

Algorithm 3: Find the factorial of a number


Step 1: Start
Step 2: Declare variables n, factorial and i.
Step 3: Initialize variables
factorial ← 1
i←1
Step 4: Read value of n
Step 5: Repeat the steps until i = n
5.1: factorial ← factorial*i
5.2: i ← i+1
Step 6: Display factorial
Step 7: Stop
Pseudocode :
Pseudocode is a combination of two words pseudo mean fake and code literally mean
fake code. In computer science, pseudocode is a plain language description of the steps in an
algorithm or another system. Pseudocode often uses structural conventions of a normal
programming language, but is intended for human reading rather than machine reading.
Pseudocode is an artificial and informal language that helps programmers develop
algorithms. Pseudocode is a "text-based" detail (algorithmic) design tool. The rules of
Pseudocode are reasonably straightforward. All statements showing "dependency" are to be
indented. These include while, do, for, if, switch.
Flowchart:
Flowchart is a pictorial representation of logic used in a computer programming. We can
also said that flowchart is a planning technique used in program .a flowchart representing a
different symbols containing information about step of sequence and events .
ANSI (American national standard institute ) established standard for the symbol and
boxes that are used in flowcharting. the shape of the boxes represent the type of activity that are
used to be performed.

Page 3
Prepared by : Sir Noman Khan class XII

Flowchart Symbol and Function:

Page 4
Prepared by : Sir Noman Khan class XII

Use of a flowchart
Following are the uses of a flowchart:
 It is a pictorial representation of an algorithm that increases the readability of the
program.
 Complex programs can be drawn in a simple way using a flowchart.
 It helps team members get an insight into the process and use this knowledge to collect
data, detect problems, develop software, etc.
 A flowchart is a basic step for designing a new process or add extra features.
 Communication with other people becomes easy by drawing flowcharts and sharing
them.
Advantages of Flowchart
 It is the most efficient way of communicating the logic of system.
 It act like a guide for blueprint during program designed.
 It also helps in debugging process.
 Using flowchart we can easily analyze the programs.
 flowcharts are good for documentation.
Disadvantages of Flowchart
 Flowcharts are difficult to draw for large and complex programs.
 It does not contain the proper amount of details.
 Flowcharts are very difficult to reproduce.
 Flowcharts are very difficult to modify.

Type of Flowchart :
There are four type of flowchart each type can be recognized by the futures given in the
following description.
Sequential Flowchart :
This is the simplest type of a flowchart , involving no decision , branches or loops.
Branch or Jump Flowchart :
Such flowchart which have one or more than one decision boxes and action takes
depends upon whether the result of the decision is called branch or jump flowchart. We can also
say branching is used in a flowchart when we want to represent the testing of a condition. A
particular path is selected based on the result of the test.
Loop Flowchart :
A loop represent a procedure which may be repeated a definite or indefinite number of
time. The for loop is a control flow statement that's used to iterate through a sequence of values.
The while loop is a control flow statement that allows you to continuously execute commands as
long as a condition evaluates to true.

Page 5
Prepared by : Sir Noman Khan class XII

Nested loop in a flowchart :


Nested Loop in Flowchart is nesting a loop inside a loop. In many conditions we may
want to run multiple loops in a flowchart. If we run a loop inside another loop the whole
structure is called Nested loop.
Categories of flowchart :

Flowchart

System flowchart Program / logic flowchart

Micro flowchart Macro flowchart

System Flowchart:
System flowcharts are a way of displaying how data flows in a system and how decisions
are made to control events. System flowchart is a type of flowchart that explains the functionality
of an entire system.
Program Flowchart:
The program flowchart is a data flow that shows the data flow while writing a program or
algorithm. a program flowchart is a type of flowchart that explains how a particular program
solves a given task.
The program flowchart further classified into two type :
1. Micro Flowchart :
It is also called Detailed Flowchart (Micro flowchart) Shows all details necessary
to capture exactly how a process is done.
2. Macro Flowchart :
Macro Flow Chart -Shows only the major steps of the process and Shows the major
steps of a process of all the events (major and as well as minor ).
Control Structure :
In a program control structure control how the program execute . algorithm flowchart and
their equivalent computer programs are more easily understand. There are three type of logic or
flow of control which are as follow .
1. Sequence logic or sequential flow
2. Selection logic or conditional flow
3. Iteration logic or repetitive flow

Page 6
Prepared by : Sir Noman Khan class XII

Sequence :
It is a serial or sequential flow of program or data in which the flow depends on the series
of instructions given to the computer. The sequences may be given, by means of numbered steps
explicitly. Also, implicitly follows the order in which modules are written. Most of the
processing, even some complex problems, will generally follow this elementary flow pattern.

Selection :
Selection Logic simply involves a number of conditions or parameters which decides one
out of several written modules. The structures which use these type of logic are known
as Conditional Structures. These structures can be of three types:
1. if
2. if/else
3. switch

Iteration:
Iteration is often referred to as a loop. Because program will keep reputing the activates
until the condition are false. which involves a repeat statement followed by a module known as
the body of a loop. there are three types of loops:
1. while
2. do/while
3. for

Page 7
Prepared by : Sir Noman Khan class XII

Page 8

You might also like