SlideShare a Scribd company logo
Unit 1
 Flowchart: Elements, Identifying and understanding
input/ output, Branching and iteration in flowchart
 Algorithm design: Problem solving approach(top
down/bottom up approach)
 Pseudo Code : Representation of different construct,
writing pseudo-code from algorithm and flowchart
Programming:
A typical programming task can be divided into two phases:
a) Problem solving phase: produce an ordered sequence of steps that
describe solution of problem. This sequence of steps is called an algorithm.
b) Implementation phase: Implement the program in some programming
language.
• A computer performs many tasks exactly in the same manner as it is told to do.
• This places responsibility on the user to instruct the computer in a correct and precise
manner, so that the machine is able to perform the required job in a proper way.
• A wrong or ambiguous instruction may sometimes prove disastrous. In order to instruct a
computer correctly, the user must have clear understanding of the problem to be solved.
• A part from this he should be able to develop a method, in the form of series of
sequential steps, to solve it.
• Once the problem is well-defined and a method of solving it is developed, then
instructing he computer to solve the problem becomes relatively easier task.
Problem Solving
• A computer cannot solve a problem on its own. One has to provide step by step solutions of the
problem to the computer. In fact, the task of problem solving is not that of the computer.
• It is the programmer who has to write down the solution to the problem in terms of simple
operations which the computer can understand and execute.
• In order to solve a problem by the computer, one has to pass though certain stages or steps.
They are :
1. Understanding the problem
2. Analyzing the problem
3. Outline problem requirements
4. Developing the solution/algorithm
5. Coding and implementation
1. Understanding the problem: Here we try to understand the problem to be solved in totally. Before
with the next stage or step, we should be absolutely sure about the objectives of the given problem.
2. Analyzing the problem: After understanding thoroughly the problem to be solved, we look different
ways of solving the problem and evaluate each of these methods. The idea here is to search an
appropriate solution to the problem under consideration. The end result of this stage is a broad
overview of the sequence of operations that are to be carries out to solve the given problem.
3. Outline problem requirements: identify requirements of the problem in terms of number of
variables required, formula etc
4. Developing the solution/algorithm: Here the overview of the sequence of operations that was the
result of analysis stage is expanded to form a detailed step by step solution to the problem under
consideration.
5. Coding and implementation: The last stage of the problem solving is the conversion of the detailed
sequence of operations in to a language that the computer can understand. Here each step is
converted to its equivalent instruction or instructions in the computer language that has been chosen
for the implantation.
Analyze the problem
1) Thoroughly understand the problem
2) Understand problem requirements
 does the program require interaction?
 does program manipulate data?
what will be the output?
3) If the problem is complex, divide it into subproblems
analyse each sub problem as above
Algorithm
Definition: A set of sequential steps that define how a task is to be performed.
• Solves a well specified problem in a general way.
• Algorithm remains the same independent of:
Which kind of hardware it is running on
Which programming language it is written in
• It may be possible to solve to problem in more than one ways, resulting in more than one
algorithm.
• The choice of various algorithms depends on the factors like reliability, accuracy and easy to modify.
• The most important factor in the choice of algorithm is the time requirement to execute it, after
writing code in High-level language with the help of a computer.
• The algorithm which will need the least time when executed is considered the best.
Algorithm Properties/characteristics
1. Input/output: Each algorithm must take zero, one or more quantities as input data
produce one or more output values.
2. Finiteness: An algorithm must terminate in a finite number of steps
3. Definiteness: Each step of the algorithm must be precisely and unambiguously stated
4. Effectiveness: Each step must be effective, in the sense that it should be primitive easily
(convert able into program statement) can be performed exactly in a finite amount of time.
5. Generality: The algorithm must be complete in itself so that it can be used to solve
problems of a specific type for any input data.
An algorithm can be written in English like sentences or in any standard representation
sometimes, algorithm written in English like languages are called Pseudo Code
Steps involved in algorithm development
• An algorithm can be defined as “a complete, unambiguous, finite number of logical
steps for solving a specific problem “
• Step1. Identify input: For an algorithm, there are quantities to be supplied called
input and these are fed externally. The input is to be identified first for any specified
problem.
• Step2: Identify output: From an algorithm, at least one quantity is produced, called
for any specified problem.
• Step3 : Identify processing operations : All the calculations to be performed in order
to lead to output from the input are to be identified in an orderly manner.
• Step4: Processing Finiteness : If we go through the algorithm, then for all cases, the
algorithm should terminate after a finite number of steps.
Algorithm constructs
1) Sequence
a number of instructions are processed one after another.
statement 1;
statement 1;
statement 1;
2) Decision /selection
The next instruction to be executed depends on a 'condition’ :
if (condition is true) then
statement 1;
else
statement 2;
else
statement 3;
end if
3) Iteration
if want to perform a number of steps again and again
a) …. A fixed number of times
for 20 times do
statement 1;
statement 2;
……………
end do
b) ….. Until a condition is met
Example 1 : write algorithm to find the average of three numbers
• Step 1 start
• Step 2 Read the numbers a, b, c
• Step 3 Compute the sum of a, b and c
• Step 4 Divide the sum by 3
• Step 5 Store the result in variable d
• Step 6 Print the value of d
• Step 7 End
Example 2 : Write an algorithm to calculate the simple interest using the formula.
Simple interest = P*N* R/100.
Where P is principle Amount, N is the number of years and R is the rate of interest.
Step 1: start
Step 2 : Read the three input quantities’ P, N and R.
Step 3 : Calculate simple interest as Simple interest = P* N* R/100
Step 4: Print simple interest.
Step 5: Stop.
Example: Write an algorithm to calculate the perimeter and area of
rectangle. Given its length and width.
Step 1: start
Step 2: Read length of the rectangle.
Step 3: Read width of the rectangle.
Step 4: Calculate perimeter of the rectangle using the formula
perimeter = 2* (length + width)
Step 5: Calculate area of the rectangle using the formula
area = length *width.
Step 6: Print perimeter.
Step 7: Print area.
Step 8: Stop.
Questions : write algorithm and program
1) The distance between two cities(in km) is input through the keyboard. Write an algorithm and
program to convert and print this distance in meters, feet, inches and centimeters
2) Two numbers are input through the keyboard into locations C and D. write an algorithm and
program to interchange the contents of C and D
3) Write an algorithm to find whether the number is even or odd.
4) Write an algorithm to print whether the
5) Write an algorithm to print sum, mult, sub, div of two numbers
6) Write an algorithm to calculate simple interest.
7) Write an algorithm to read 3 numbers from the user. Print their sum and average.
8) Write an algorithm to read basic salary from the user and compute HRA – 12% of basic, DA- 64%
of basic, allowance -15% of basic. Also display total salary.
9) Write an algorithm to find area and perimeter of square
10) Write an algorithm to find area and perimeter of circle
11) Write an algorithm to find area of triangle using hero’s formula
Algorithm design:
Problem solving approach
(top down/bottom up approach)
• A programming approach is nothing but way of solving the computational
problem.
• Two approaches:
a) Top down
b) Bottom up
Top down approach
• “top down” approach is nothing but resolving the problem from high level to low level.
Basically you start from the whole problem.
• Top down :
1) Take the whole problem and split it into two or more parts.
2) Find solution to these parts.
3) If these parts turn out to be too big to be solved as a whole, split them further and find
find solutions to those sub-parts.
4) Merge solutions according to the sub-problem hierarchy thus created after all parts have
been successfully solved.
Bottom up approach
• In "bottom up" approach, you identify lower-level tools that you can compose to become a
bigger program. Basically you focus on parts of the problem to solve it.
• Bottom up :
1) Breaking the problem into smallest possible(and practical) parts.
2) Finding solutions to these small sub-problems.
3) Merging the solutions you get iteratively(again and again) till you have merged all of them
to get the final solution to the "big"
problem.
The main difference in approach is splitting versus merging. You either start big and split
"down" as required or start with the smallest and merge your way "up" to the final solution.
Program structure in top down Vs bottom up approach
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
Role of sub algorithm
• Algorithms are often broken down into smaller chunks, called Subalgorithm. This is both so that they are easier to
read, and also because then parts of the algorithm can be reused.
• A sub-algorithm is an algorithmic module which is complete in itself and has independent existence.
• It can be used or called by some main algorithm or by some other sub-algorithm.
• It may or may not receive values from a calling algorithm. These values are called arguments or
parameters.
• The sub-algorithm performs its task and then sends back the result to the calling algorithm. It can be
called by many different algorithms or called at different places in the same algorithm.
• The relationship between an algorithm and a sub-algorithm is similar to the relationship between a
main program (function) and a sub-program (sub-function) in a programming language.
Usefulness
• When the problem is very complex, it is divided into several independent
sub-problems. Each sub-problem is called sub-algorithm and can be
developed independently. These sub-problems can be combined together to
form the solution for the entire problem. Thus by using sub-algorithms the
complex problems can be solved easily.
Questions
1) C follows top down or bottom up approach? Why?
2) Give names of programming language which follows top down and
bottom up approach.
3) What is the role of subalgorithm? What is relationship between main
algorithm and sub algorithm?
Assignment: write algorithm
1) The current year and the year in which the employee joined the organization are entered through the keyboard.
If the number of years for which the employee has served the organization is greater than 3 then a bonus of
Rs. 2500/- is given to the employee. If the years of service are not greater than 3, then the program should do
nothing.
2) In a company an employee is paid as under:
If his basic salary is less than Rs. 1500, then HRA = 10% of basic salary and DA = 90% of basic salary. If his
salary is either equal to or above Rs. 1500, then HRA = Rs. 500 and DA = 98% of basic salary. If the employee's
salary is input through the keyboard write a program to find his gross salary.
3) The marks obtained by a student in 5 different subjects are input through the keyboard. The student gets a
division as per the following rules:
Percentage above or equal to 60 - First division
Percentage between 50 and 59 - Second division
Percentage between 40 and 49 - Third division Percentage less than 40 - Fail
calculate the division obtained by the student.
4) Calculate salary
5) If the ages of Ram, Shyam and Ajay are input through the keyboard. determine the youngest of the three.
6) Two numbers are input through the keyboard into locations C and D. write an algorithm and program to interchange the
contents of C and D
7)Write an algorithm to find whether the number is even or odd.
8) Write algorithm to check whether a triangle is valid or not, when the three angles of the triangle are entered through
the keyboard. A triangle is valid if the sum of all the three angles is equal to 180 degrees.
7) A company insures its drivers in the following cases: −
- If the driver is married.
- If the driver is unmarried, male & above 30 years of age.
- If the driver is unmarried, female & above 25 years of age.
8) Any integer is input through the keyboard. find out whether it is an odd
number or even number.
9) Any year is input through the keyboard. Determine whether the year is a
leap year or not. (Hint: Use the % (modulus) operator)
Unit 1
 Flowchart: Elements, Identifying and understanding
input/ output, Branching and iteration in flowchart
 Algorithm design: Problem solving approach(top
down/bottom up approach)
 Pseudo Code : Representation of different construct,
writing pseudo-code from algorithm and flowchart
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
Unit 1
 Flowchart: Elements, Identifying and understanding
input/ output, Branching and iteration in flowchart
 Algorithm design: Problem solving approach(top
down/bottom up approach)
 Pseudo Code : Representation of different
construct, writing pseudo-code from algorithm and
flowchart
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
Like flowcharting, there are many elements to pseudocode design, only the
most
rudimentary are described here.
Get used to get information from the user
Display used to display information for the user
Compute perform an arithmetic operation
+
-
* Standard arithmetic operators
/
=
( )
Store Store a piece of information for later use
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES

More Related Content

PDF
Visual Basic 6.0
Anjan Mahanta
 
PPTX
Mealy and moore machine
Ehatsham Riaz
 
PPTX
phases of algorithm
sti meycauayan
 
PPSX
Algorithm and flowchart
Sachin Goyani
 
PPT
finding Min and max element from given array using divide & conquer
Swati Kulkarni Jaipurkar
 
DOC
Branch and bound
Nv Thejaswini
 
PPTX
Kruskal’s algorithm
Abdul Moiz Lakhani
 
PPT
digital logic design number system
Nallapati Anindra
 
Visual Basic 6.0
Anjan Mahanta
 
Mealy and moore machine
Ehatsham Riaz
 
phases of algorithm
sti meycauayan
 
Algorithm and flowchart
Sachin Goyani
 
finding Min and max element from given array using divide & conquer
Swati Kulkarni Jaipurkar
 
Branch and bound
Nv Thejaswini
 
Kruskal’s algorithm
Abdul Moiz Lakhani
 
digital logic design number system
Nallapati Anindra
 

What's hot (20)

PPT
Data structures & problem solving unit 1 ppt
aviban
 
PPT
minimum spanning tree
Melaku Bayih Demessie
 
PPTX
Variables, Data Types, Operator & Expression in c in detail
gourav kottawar
 
PPTX
Alpha-beta pruning (Artificial Intelligence)
Falak Chaudry
 
PPTX
Programacion Modular
Franco Guamán
 
PPT
Backtracking Algorithm.ppt
SalmIbrahimIlyas
 
PPT
Programming in c
indra Kishor
 
PDF
, Programacion java
Pablo Robert Lopez Nicolaz
 
PPTX
Operators and expressions in c language
tanmaymodi4
 
PPTX
Presentation on Karnaugh Map
Kawsar Ahmed
 
PPTX
Greedy method
Anusha sivakumar
 
DOCX
Recursion in C++
Maliha Mehr
 
PPTX
Coin change Problem (DP & GREEDY)
Ridhima Chowdhury
 
PPTX
asymptotic notation
SangeethaSasi1
 
PPTX
Greedy Algorithm - Knapsack Problem
Madhu Bala
 
PPT
Computer Programming - Lecture 2
Dr. Md. Shohel Sayeed
 
PPT
asymptotic notations i
Ali mahmood
 
PPTX
My presentation minimum spanning tree
Alona Salva
 
PPTX
Sum of subset problem.pptx
V.V.Vanniaperumal College for Women
 
Data structures & problem solving unit 1 ppt
aviban
 
minimum spanning tree
Melaku Bayih Demessie
 
Variables, Data Types, Operator & Expression in c in detail
gourav kottawar
 
Alpha-beta pruning (Artificial Intelligence)
Falak Chaudry
 
Programacion Modular
Franco Guamán
 
Backtracking Algorithm.ppt
SalmIbrahimIlyas
 
Programming in c
indra Kishor
 
, Programacion java
Pablo Robert Lopez Nicolaz
 
Operators and expressions in c language
tanmaymodi4
 
Presentation on Karnaugh Map
Kawsar Ahmed
 
Greedy method
Anusha sivakumar
 
Recursion in C++
Maliha Mehr
 
Coin change Problem (DP & GREEDY)
Ridhima Chowdhury
 
asymptotic notation
SangeethaSasi1
 
Greedy Algorithm - Knapsack Problem
Madhu Bala
 
Computer Programming - Lecture 2
Dr. Md. Shohel Sayeed
 
asymptotic notations i
Ali mahmood
 
My presentation minimum spanning tree
Alona Salva
 
Sum of subset problem.pptx
V.V.Vanniaperumal College for Women
 
Ad

Similar to C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES (20)

PPTX
Algorithm types performance steps working
Saurabh846965
 
PPTX
Algorithm for computational problematic sit
Saurabh846965
 
PDF
Algorithm.pdf
MIT,Imphal
 
PPTX
Chp-1 DAA (2).pptx design analysis and algoritham presentation
vaishnavbhavna17
 
PPTX
Module 1 python.pptx
AnuragJoshi813963
 
PPT
Unit 1 python (2021 r)
praveena p
 
PDF
PROGRAMMING IN C UNIT I.pdffffffffffffffffffffffffd
dinesh620610
 
PDF
Introduction to Problem Solving Techniques
Sitamarhi Institute of Technology
 
PDF
Problem solving techniques in c language
John Bruslin
 
PDF
Study Material for Problem Solving Techniques
Bobby Murugesan
 
PPT
Problem Solving Techniques notes for Unit 1
SATHYABAMAMADHANKUMA
 
PDF
Fundamental of Information Technology - UNIT 6
Shipra Swati
 
PDF
Python Unit 1.pdfPython Notes for Bharathiar university syllabus
ANUSUYA S
 
PPTX
01 Introduction to analysis of Algorithms.pptx
ssuser586772
 
PDF
Logic Development and Algorithm.
NandiniSidana
 
PDF
Algorithms notes 2 tutorials duniya
TutorialsDuniya.com
 
PPT
UNIT-1-PPT-DESIGN AND ANALYSIS OF ALGORITHMS
ramalakshmikaliappan
 
PPTX
ANALYSIS AND DESIGN OF ALGORITHMS -M1-PPT
AIET
 
PPTX
Introduction to problem solving Techniques
merlinjohnsy
 
PPT
C programming for Computing Techniques
Appili Vamsi Krishna
 
Algorithm types performance steps working
Saurabh846965
 
Algorithm for computational problematic sit
Saurabh846965
 
Algorithm.pdf
MIT,Imphal
 
Chp-1 DAA (2).pptx design analysis and algoritham presentation
vaishnavbhavna17
 
Module 1 python.pptx
AnuragJoshi813963
 
Unit 1 python (2021 r)
praveena p
 
PROGRAMMING IN C UNIT I.pdffffffffffffffffffffffffd
dinesh620610
 
Introduction to Problem Solving Techniques
Sitamarhi Institute of Technology
 
Problem solving techniques in c language
John Bruslin
 
Study Material for Problem Solving Techniques
Bobby Murugesan
 
Problem Solving Techniques notes for Unit 1
SATHYABAMAMADHANKUMA
 
Fundamental of Information Technology - UNIT 6
Shipra Swati
 
Python Unit 1.pdfPython Notes for Bharathiar university syllabus
ANUSUYA S
 
01 Introduction to analysis of Algorithms.pptx
ssuser586772
 
Logic Development and Algorithm.
NandiniSidana
 
Algorithms notes 2 tutorials duniya
TutorialsDuniya.com
 
UNIT-1-PPT-DESIGN AND ANALYSIS OF ALGORITHMS
ramalakshmikaliappan
 
ANALYSIS AND DESIGN OF ALGORITHMS -M1-PPT
AIET
 
Introduction to problem solving Techniques
merlinjohnsy
 
C programming for Computing Techniques
Appili Vamsi Krishna
 
Ad

Recently uploaded (20)

PPTX
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
PPTX
Presentation about variables and constant.pptx
kr2589474
 
PDF
Micromaid: A simple Mermaid-like chart generator for Pharo
ESUG
 
PPTX
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
PPT
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
PDF
Why Use Open Source Reporting Tools for Business Intelligence.pdf
Varsha Nayak
 
PDF
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
PPTX
Explanation about Structures in C language.pptx
Veeral Rathod
 
PPTX
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
PDF
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
PDF
Protecting the Digital World Cyber Securit
dnthakkar16
 
PPTX
Why Use Open Source Reporting Tools for Business Intelligence.pptx
Varsha Nayak
 
PPT
Activate_Methodology_Summary presentatio
annapureddyn
 
PDF
Become an Agentblazer Champion Challenge Kickoff
Dele Amefo
 
PDF
Appium Automation Testing Tutorial PDF: Learn Mobile Testing in 7 Days
jamescantor38
 
PDF
Key Features to Look for in Arizona App Development Services
Net-Craft.com
 
PDF
Microsoft Teams Essentials; The pricing and the versions_PDF.pdf
Q-Advise
 
PDF
Jenkins: An open-source automation server powering CI/CD Automation
SaikatBasu37
 
PPTX
Role Of Python In Programing Language.pptx
jaykoshti048
 
PPTX
PFAS Reporting Requirements 2026 Are You Submission Ready Certivo.pptx
Certivo Inc
 
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
Presentation about variables and constant.pptx
kr2589474
 
Micromaid: A simple Mermaid-like chart generator for Pharo
ESUG
 
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
Why Use Open Source Reporting Tools for Business Intelligence.pdf
Varsha Nayak
 
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
Explanation about Structures in C language.pptx
Veeral Rathod
 
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
Protecting the Digital World Cyber Securit
dnthakkar16
 
Why Use Open Source Reporting Tools for Business Intelligence.pptx
Varsha Nayak
 
Activate_Methodology_Summary presentatio
annapureddyn
 
Become an Agentblazer Champion Challenge Kickoff
Dele Amefo
 
Appium Automation Testing Tutorial PDF: Learn Mobile Testing in 7 Days
jamescantor38
 
Key Features to Look for in Arizona App Development Services
Net-Craft.com
 
Microsoft Teams Essentials; The pricing and the versions_PDF.pdf
Q-Advise
 
Jenkins: An open-source automation server powering CI/CD Automation
SaikatBasu37
 
Role Of Python In Programing Language.pptx
jaykoshti048
 
PFAS Reporting Requirements 2026 Are You Submission Ready Certivo.pptx
Certivo Inc
 

C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES

  • 1. Unit 1  Flowchart: Elements, Identifying and understanding input/ output, Branching and iteration in flowchart  Algorithm design: Problem solving approach(top down/bottom up approach)  Pseudo Code : Representation of different construct, writing pseudo-code from algorithm and flowchart
  • 2. Programming: A typical programming task can be divided into two phases: a) Problem solving phase: produce an ordered sequence of steps that describe solution of problem. This sequence of steps is called an algorithm. b) Implementation phase: Implement the program in some programming language.
  • 3. • A computer performs many tasks exactly in the same manner as it is told to do. • This places responsibility on the user to instruct the computer in a correct and precise manner, so that the machine is able to perform the required job in a proper way. • A wrong or ambiguous instruction may sometimes prove disastrous. In order to instruct a computer correctly, the user must have clear understanding of the problem to be solved. • A part from this he should be able to develop a method, in the form of series of sequential steps, to solve it. • Once the problem is well-defined and a method of solving it is developed, then instructing he computer to solve the problem becomes relatively easier task.
  • 4. Problem Solving • A computer cannot solve a problem on its own. One has to provide step by step solutions of the problem to the computer. In fact, the task of problem solving is not that of the computer. • It is the programmer who has to write down the solution to the problem in terms of simple operations which the computer can understand and execute. • In order to solve a problem by the computer, one has to pass though certain stages or steps. They are : 1. Understanding the problem 2. Analyzing the problem 3. Outline problem requirements 4. Developing the solution/algorithm 5. Coding and implementation
  • 5. 1. Understanding the problem: Here we try to understand the problem to be solved in totally. Before with the next stage or step, we should be absolutely sure about the objectives of the given problem. 2. Analyzing the problem: After understanding thoroughly the problem to be solved, we look different ways of solving the problem and evaluate each of these methods. The idea here is to search an appropriate solution to the problem under consideration. The end result of this stage is a broad overview of the sequence of operations that are to be carries out to solve the given problem. 3. Outline problem requirements: identify requirements of the problem in terms of number of variables required, formula etc 4. Developing the solution/algorithm: Here the overview of the sequence of operations that was the result of analysis stage is expanded to form a detailed step by step solution to the problem under consideration. 5. Coding and implementation: The last stage of the problem solving is the conversion of the detailed sequence of operations in to a language that the computer can understand. Here each step is converted to its equivalent instruction or instructions in the computer language that has been chosen for the implantation.
  • 6. Analyze the problem 1) Thoroughly understand the problem 2) Understand problem requirements  does the program require interaction?  does program manipulate data? what will be the output? 3) If the problem is complex, divide it into subproblems analyse each sub problem as above
  • 7. Algorithm Definition: A set of sequential steps that define how a task is to be performed. • Solves a well specified problem in a general way. • Algorithm remains the same independent of: Which kind of hardware it is running on Which programming language it is written in • It may be possible to solve to problem in more than one ways, resulting in more than one algorithm. • The choice of various algorithms depends on the factors like reliability, accuracy and easy to modify. • The most important factor in the choice of algorithm is the time requirement to execute it, after writing code in High-level language with the help of a computer. • The algorithm which will need the least time when executed is considered the best.
  • 8. Algorithm Properties/characteristics 1. Input/output: Each algorithm must take zero, one or more quantities as input data produce one or more output values. 2. Finiteness: An algorithm must terminate in a finite number of steps 3. Definiteness: Each step of the algorithm must be precisely and unambiguously stated 4. Effectiveness: Each step must be effective, in the sense that it should be primitive easily (convert able into program statement) can be performed exactly in a finite amount of time. 5. Generality: The algorithm must be complete in itself so that it can be used to solve problems of a specific type for any input data. An algorithm can be written in English like sentences or in any standard representation sometimes, algorithm written in English like languages are called Pseudo Code
  • 9. Steps involved in algorithm development • An algorithm can be defined as “a complete, unambiguous, finite number of logical steps for solving a specific problem “ • Step1. Identify input: For an algorithm, there are quantities to be supplied called input and these are fed externally. The input is to be identified first for any specified problem. • Step2: Identify output: From an algorithm, at least one quantity is produced, called for any specified problem. • Step3 : Identify processing operations : All the calculations to be performed in order to lead to output from the input are to be identified in an orderly manner. • Step4: Processing Finiteness : If we go through the algorithm, then for all cases, the algorithm should terminate after a finite number of steps.
  • 10. Algorithm constructs 1) Sequence a number of instructions are processed one after another. statement 1; statement 1; statement 1; 2) Decision /selection The next instruction to be executed depends on a 'condition’ : if (condition is true) then statement 1; else statement 2; else statement 3; end if
  • 11. 3) Iteration if want to perform a number of steps again and again a) …. A fixed number of times for 20 times do statement 1; statement 2; …………… end do b) ….. Until a condition is met
  • 12. Example 1 : write algorithm to find the average of three numbers • Step 1 start • Step 2 Read the numbers a, b, c • Step 3 Compute the sum of a, b and c • Step 4 Divide the sum by 3 • Step 5 Store the result in variable d • Step 6 Print the value of d • Step 7 End
  • 13. Example 2 : Write an algorithm to calculate the simple interest using the formula. Simple interest = P*N* R/100. Where P is principle Amount, N is the number of years and R is the rate of interest. Step 1: start Step 2 : Read the three input quantities’ P, N and R. Step 3 : Calculate simple interest as Simple interest = P* N* R/100 Step 4: Print simple interest. Step 5: Stop.
  • 14. Example: Write an algorithm to calculate the perimeter and area of rectangle. Given its length and width. Step 1: start Step 2: Read length of the rectangle. Step 3: Read width of the rectangle. Step 4: Calculate perimeter of the rectangle using the formula perimeter = 2* (length + width) Step 5: Calculate area of the rectangle using the formula area = length *width. Step 6: Print perimeter. Step 7: Print area. Step 8: Stop.
  • 15. Questions : write algorithm and program 1) The distance between two cities(in km) is input through the keyboard. Write an algorithm and program to convert and print this distance in meters, feet, inches and centimeters 2) Two numbers are input through the keyboard into locations C and D. write an algorithm and program to interchange the contents of C and D 3) Write an algorithm to find whether the number is even or odd. 4) Write an algorithm to print whether the 5) Write an algorithm to print sum, mult, sub, div of two numbers 6) Write an algorithm to calculate simple interest. 7) Write an algorithm to read 3 numbers from the user. Print their sum and average. 8) Write an algorithm to read basic salary from the user and compute HRA – 12% of basic, DA- 64% of basic, allowance -15% of basic. Also display total salary. 9) Write an algorithm to find area and perimeter of square 10) Write an algorithm to find area and perimeter of circle 11) Write an algorithm to find area of triangle using hero’s formula
  • 16. Algorithm design: Problem solving approach (top down/bottom up approach)
  • 17. • A programming approach is nothing but way of solving the computational problem. • Two approaches: a) Top down b) Bottom up
  • 18. Top down approach • “top down” approach is nothing but resolving the problem from high level to low level. Basically you start from the whole problem. • Top down : 1) Take the whole problem and split it into two or more parts. 2) Find solution to these parts. 3) If these parts turn out to be too big to be solved as a whole, split them further and find find solutions to those sub-parts. 4) Merge solutions according to the sub-problem hierarchy thus created after all parts have been successfully solved.
  • 19. Bottom up approach • In "bottom up" approach, you identify lower-level tools that you can compose to become a bigger program. Basically you focus on parts of the problem to solve it. • Bottom up : 1) Breaking the problem into smallest possible(and practical) parts. 2) Finding solutions to these small sub-problems. 3) Merging the solutions you get iteratively(again and again) till you have merged all of them to get the final solution to the "big" problem. The main difference in approach is splitting versus merging. You either start big and split "down" as required or start with the smallest and merge your way "up" to the final solution.
  • 20. Program structure in top down Vs bottom up approach
  • 22. Role of sub algorithm • Algorithms are often broken down into smaller chunks, called Subalgorithm. This is both so that they are easier to read, and also because then parts of the algorithm can be reused. • A sub-algorithm is an algorithmic module which is complete in itself and has independent existence. • It can be used or called by some main algorithm or by some other sub-algorithm. • It may or may not receive values from a calling algorithm. These values are called arguments or parameters. • The sub-algorithm performs its task and then sends back the result to the calling algorithm. It can be called by many different algorithms or called at different places in the same algorithm. • The relationship between an algorithm and a sub-algorithm is similar to the relationship between a main program (function) and a sub-program (sub-function) in a programming language.
  • 23. Usefulness • When the problem is very complex, it is divided into several independent sub-problems. Each sub-problem is called sub-algorithm and can be developed independently. These sub-problems can be combined together to form the solution for the entire problem. Thus by using sub-algorithms the complex problems can be solved easily.
  • 24. Questions 1) C follows top down or bottom up approach? Why? 2) Give names of programming language which follows top down and bottom up approach. 3) What is the role of subalgorithm? What is relationship between main algorithm and sub algorithm?
  • 25. Assignment: write algorithm 1) The current year and the year in which the employee joined the organization are entered through the keyboard. If the number of years for which the employee has served the organization is greater than 3 then a bonus of Rs. 2500/- is given to the employee. If the years of service are not greater than 3, then the program should do nothing. 2) In a company an employee is paid as under: If his basic salary is less than Rs. 1500, then HRA = 10% of basic salary and DA = 90% of basic salary. If his salary is either equal to or above Rs. 1500, then HRA = Rs. 500 and DA = 98% of basic salary. If the employee's salary is input through the keyboard write a program to find his gross salary. 3) The marks obtained by a student in 5 different subjects are input through the keyboard. The student gets a division as per the following rules: Percentage above or equal to 60 - First division Percentage between 50 and 59 - Second division Percentage between 40 and 49 - Third division Percentage less than 40 - Fail calculate the division obtained by the student.
  • 26. 4) Calculate salary 5) If the ages of Ram, Shyam and Ajay are input through the keyboard. determine the youngest of the three. 6) Two numbers are input through the keyboard into locations C and D. write an algorithm and program to interchange the contents of C and D 7)Write an algorithm to find whether the number is even or odd. 8) Write algorithm to check whether a triangle is valid or not, when the three angles of the triangle are entered through the keyboard. A triangle is valid if the sum of all the three angles is equal to 180 degrees.
  • 27. 7) A company insures its drivers in the following cases: − - If the driver is married. - If the driver is unmarried, male & above 30 years of age. - If the driver is unmarried, female & above 25 years of age. 8) Any integer is input through the keyboard. find out whether it is an odd number or even number. 9) Any year is input through the keyboard. Determine whether the year is a leap year or not. (Hint: Use the % (modulus) operator)
  • 28. Unit 1  Flowchart: Elements, Identifying and understanding input/ output, Branching and iteration in flowchart  Algorithm design: Problem solving approach(top down/bottom up approach)  Pseudo Code : Representation of different construct, writing pseudo-code from algorithm and flowchart
  • 49. Unit 1  Flowchart: Elements, Identifying and understanding input/ output, Branching and iteration in flowchart  Algorithm design: Problem solving approach(top down/bottom up approach)  Pseudo Code : Representation of different construct, writing pseudo-code from algorithm and flowchart
  • 52. Like flowcharting, there are many elements to pseudocode design, only the most rudimentary are described here. Get used to get information from the user Display used to display information for the user Compute perform an arithmetic operation + - * Standard arithmetic operators / = ( ) Store Store a piece of information for later use