Planning of Computer Programming- In today word a
computer is used to solve various types of problems because
it takes very less time as compared to a human being.
1. Analyze the given problem
2. Divide the process used to solve the problem in a series of
elementary task.
3. Formulate the algorithm to solve the problem.
Now in other words we say that “program must be planned
before they are written”.
Basic of Computer & 'c' Programming 1
Flow charts:- A flowchart is a pictorial
representation of an algorithm. It is after used
by programmers as a program-planning tools
for organizing a sequence of steps necessary to
solve a problem by a computer.
Basic of Computer & 'c' Programming 2
1. Flowchart symbol :- The terminal is
used to indicate the beginning (start), end
(stop) and pauses (Halt) in the program logic
flow.
2. Input/output :- Is used to denote
any function of an input/output device in the
program.
3. Processing :- Is used for arithmetic &
data movement instruction.
Basic of Computer & 'c' Programming 3
4. Decision :- Is used to indicate a point at
which a decision has to made and a branch to one of two
or move alternative points is possible.
5. Flow Lines :- is indication flow of operation.
6. Connectors :- Connector to used a substitute for
flow lines user a flow chart becomes complex the number
and direction of How lines is confusing or it spreads over
more than one page.
Basic of Computer & 'c' Programming 4
Advantage of flowchart:-
•Better Communication
•Proper Program Documentation
•Efficient coding
•Systematic Debugged
•Systematic Testing
Basic of Computer & 'c' Programming 5
Limitation:- It time consuming and laborious
to draw with proper symbols and spacing
especially for large complex programs.
Basic of Computer & 'c' Programming 6
Algorithm:- It is logic of a program, precise
step by step method for solving a problem
independently of the S/W or H/W of the
computer. Algorithm is very essential as they
instruct the computer what specific step it
needs to perform to carry out a particular task
or to solve a problem.
Basic of Computer & 'c' Programming 7
Characteristics of Algorithm:-
A well-defined algorithm has five basic
characteristics.
•Input: Every Algorithm must accept with
required input data.
Ex.: Read N, Sum;
•Output: Every Algorithm will have one or
more outputs.
Ex.: Print N, Sum;
Basic of Computer & 'c' Programming 8
•Definiteness: - Every step must be clear, well
defined & precise. There should not be any
ambiguity.
•Finiteness: - An algorithm must always
terminate in finite time & finite number of steps.
It should not enter an infinite loop
•Effectiveness: - The steps must be sufficiently
basic, so that the calculation can be performed
normally.
Basic of Computer & 'c' Programming 9
1. Write an Algorithm to calculate the area & circumference of a circle.
Step 1. Start
Step 2. Read the value of Radius as R
Step 3. Compute Area = 3.142 * R * R
[Area of circle is calculated by using the formula = R2]
Step 4. Compute Circum = 2 * 3.142 * R
[Circumference of a circle is calculated by using the formula = 2R]
Step 5. Print the results Area and Circum
Step 6. End of algorithm [STOP]
Basic of Computer & 'c' Programming 10
2 Find the largest number among three numbers
Step 1. Start
Start 2. Read 3 numbers as A, B, C
Step 3. Compare A with B and C like If A> B then followed by A>C
Step 4. If the conditions are true, then print “A is large”
Step 5. If A>B condition is False then compare B> C then Print “B is
large” when the condition is true otherwise Print “C is large”.
Step 6. End of algorithm [STOP]
Basic of Computer & 'c' Programming 11
3. Find the sum of First N Natural Numbers
Step 1. Start
Start 2. Read N value
Step 3. Set Sum equal to 0 i.e., Sum 0
Step 4. Compute the sum of all N numbers from 1 to N as
For I = 1 to N in step of 1
Then Sum = Sum + I
Go to step no 3
Step 5. Print Sum of N Natural Numbers =; Sum
Step 6. End of algorithm [STOP]
Basic of Computer & 'c' Programming 12
Ex. 4 Write an algorithm for finding greatest among three No:-
Sol. Let x, y and z be the numbers. Now, we can follow the algorithm below
to determine the greatest number among the three.
Read the three no.
if x>y
if x>z, than x is the greatest No.
Eles z is the greatest No.
Eles,
if y>z, then y is the greatest.
Eles, z is the greatest No.
Basic of Computer & 'c' Programming 13
Ex 5. Write the algorithm for calculating the average
of n integer.
1.Read n integers.
2.Calculate the sum of the integer.
3.Divide the sum by the total number of integers that is n.
4.Print the final value which is the average of n integer.
Basic of Computer & 'c' Programming 14
Pseudocades:- Pseudocode is a programming
analysis tool, which allows programmers to plan
program logic by written the program instructions
in an ordinary natural language such as English.
“Pseudo” means false, and code refers to the
instruction. Written in a programming language.
Basic of Computer & 'c' Programming 15
Thanks
Basic of Computer & 'c' Programming 16