Chapter-1-Introduction Programming and Problem Solving Concepts
Chapter-1-Introduction Programming and Problem Solving Concepts
Well-Defined Outputs: The algorithm must clearly define what output will
be yielded and it should be well-defined as well.
Algorithms
Characteristics of Algorithm :
Feasible: The algorithm must be simple, generic and practical, such that it
can be executed upon with the available resources. It must not contain some
future technology, or anything.
Algorithms
Characteristics of Algorithm :
Language Independent: The Algorithm designed must be language-independent, i.e. it must be just plain instructions that can be implemented in any language, and yet the output will be same, as expected.
Algorithms
Algorithm to add two numbers
Step1: Start
Step2: Accept first number
Step3: Accept second number
Step4: Add these two number
Step5: Display result
Step6: Stop
Flowcharts
Flowcharts are the graphical representation of the data or the
algorithm.
It displays step-by-step solutions to a problem, algorithm, or process.
It describes the sequence and flow of control and information within
the process.
It uses different symbols for depicting different activities.
Flowcharts Symbols
Flowcharts
Design rules
It must begin with ‘start’ and end with ‘stop’ symbol.
Process flow should be either in top-down or from left-right.
Instruction must be crisp and concise.
Arrows must be aligned properly.
Connectors should be avoided.
Process/action must have exactly one input and one output arrow.
Flowcharts
Advantages
It helps to understand flow of program control.
Program development will be easier following flowchart.
It works well for small program design.
Disadvantages
For large program, flowchart might become complex and
confusing.
Modification of flowchart is difficult.
Preparing flowchart is tedious and time-consuming.
Algorithm-Flowchart
• Algorithm
• Step 1: Initialize X as 0,
• Step 2: Increment X by 1,
• Step 3: Print X,
• Step 4: If X is less than 20
then go back to step 2.
Practice Problem
Find Area of Circle
Calculate the average of 3 numbers
Calculate the simple interest
Calculate the sum of integers 1 to 100
To find sum of all even numbers upto ‘n’