SlideShare a Scribd company logo
1 of 16
Download to read offline
Computer Programming by Ali Asghar Manjotho 1
Practical 01
Problem analysis and program design for sequential control flow
Objectives
 Understand the basic concepts involved in solving computational problems.
 Analyzing and designing programs for sequential logic.
 To get familiar with and be able to create IPO chart for various problems.
 To get familiar with and be able to create algorithms to solve various problems.
 To get familiar with and be able to translate algorithms in to flow charts.
Tools
 Edraw Max (Version: 6.8 or 7.2)
 Microsoft Word (Version: 2007, 2010 or 2013)
Keywords: Problem solving, computational problems, sequential logic, IPO
chart, algorithm, flow chart.
Duration: 03 hours
1.1 Introduction
1.1.1 Problem solving in everyday life
People make decisions every day to solve problems that affect their lives. The problems may be as
unimportant as what to watch on television or as important as choosing a new profession. If a bad
decision is made, time and resources are wasted, so it’s important that people know how to make
decisions well. There are six steps to follow to ensure the best decision:
1. Identify the problem. The first step towards solving a problem is to identify the problem. If you
don’t know what the problem is, you cannot solve it. In a classroom situation, most problems have
been identified for you and given to you in the form of written assignments or problems out of a book.
However, when you are doing problem solving outside the classroom, you need to make sure you
identify the problem before you start solving it.
2. Understand the problem. You must understand what is involved in the problem before you can
continue toward the solution. You cannot solve a problem if you do not know the subject. For
example, to solve a problem involving average of numbers, you must know how to calculate average;
to solve a problem of trigonometry, you must know trigonometry.
Evaluate
the solution
List
instruction
to solve
problem
Select the
best
solution
Identify
alternative
solutions
Understand
the
problem
Identify the
problem
Practical 01: Problem analysis and program design for sequential control flow
2 Computer Programming by Ali Asghar Manjotho
3. Identify alternative solutions. A single problem can be solved in many different ways. Identify
and list all the possible solutions to the problem. For example there are multiple ways to sort the
numbers as: Insertion sort, Selection sort or Bubble sort.
4. Select the best solution. Analyze and identify the pros and cons of every alternative solution.
Choose the solution that is optimal and best matches with your requirements. For example out of all
the sorting options you choose bubble sort as your best solution.
5. List instructions to solve problem. Write down general step by step procedure to solve the
problem. For example to solve problem of calculating average of three numbers:
 Step 01 : Ask numbers a, b, and c from the user
 Step 02 : Add a, b, c and store result in sum
 Step 03 : Divide sum by 3 and store result in avg
 Step 04 : Display avg
6. Evaluate the solution. Finally evaluate and test the solution, means to check its result to see if it
is correct and satisfies the needs. For example, when a person needs a pen to write a letter, buying
him marker may be a correct solution, but it may not be very satisfactory. If the result is either
incorrect or unsatisfactory, then the problem solver must review the list of instructions to see that
they are correct or start the process all over again.
If any of these six steps are not completed well, the results may be less than desired. Most people use
them without even knowing it.
1.1.2 Sequential control flow
Sequential control flow also referred to as sequential logic is one of the order in which the program
instructions are executed. A program is usually composed of multiple instructions which are to be
executed by the computer. It is the default order of program execution. In sequential logic:
 A program starts at first instruction and all the instructions are executed in a sequence of one
after another.
 No any instruction is skipped out of the execution.
 Order of execution is not violated (all instruction are executed in sequence e.g. Instruction 1
then 2, followed by 3 and so on).
1.1.3 Problem analysis tools
Problem analysis is a set of activities that increase the designer’s understanding of a problem, in
order to have a better solution. Problem analysis tools help you analyze the problem to have a clear
picture of the problem. They are used to conduct postmortem of a problem.
Three of the problem analysis tools used in this practical are:
Practical 01: Problem analysis and program design for sequential control flow
Computer Programming by Ali Asghar Manjotho 3
1.1.3.1 IPO (Input Process Output) chart
IPO stands for Input Process Output. It performs the analysis by identifying the inputs, processing
items and outputs of a given problem. It can be represented by the following chart:
Input Processing Output
Processing Items:
Algorithm:
The input section specifies all the inputs to the problem. The input may be given by the user from
input devices like, keyboard, mouse, scanner etc. The input may also come as the contents of a file.
The input may come from the network or Internet.
The output section specifies all the outcomes of the problem. The output may be in the form of the
presenting the results on the monitor screen, printer or any other output device. The output may also
be stored in a file. The output may be redirected to network or Internet.
The processing section specifies two things: processing items and algorithm. The processing items
involve any formula or equation to be used while processing. The algorithm is the step by step
processing procedure to solve that task.
1.1.3.2 Algorithm
Algorithm is the representation of a solution to a problem. It is step by step procedure to solve a given
problem. An algorithm contains finite number of instructions in order to solve a problem. For
example, calculating the average of three numbers.
Step 01: Start
Step 02: Input number1, number2 and number3 from the user
Step 03: Calculate average as: average = (number1 + number2 + number3)/3
Step 04: Print average
Step 05: End
Practical 01: Problem analysis and program design for sequential control flow
4 Computer Programming by Ali Asghar Manjotho
1.1.3.3 Flow chart
Flow chart is the pictorial representation of a process or an algorithm. It uses symbols (boxes of
different shapes) to represent each step of an algorithm. All the symbols are then connected with
arrows to show the flow of the process.
Following is the list of some commonly used flow chart symbols:
Symbol Name Meaning
Terminal
(Oval)
Indicates the beginning and end
points of an algorithm.
Process
(Rectangle)
Shows an instruction other than
input, output or selection.
Input-Output
(Parallelogram)
Shows an input or output
instruction.
Decision
(Diamond)
Shows any point in the process
where decision is to be made.
On-Page Connector
Continues and connects the
flowchart on the same page.
Off-Page Connector
Continues and connects the
flowchart on another page.
Sub-Process
Denotes movement to another
process and hence a new
flowchart.
Arrows
Connects symbols and shows flow
of the process or algorithm.
Practical 01: Problem analysis and program design for sequential control flow
Computer Programming by Ali Asghar Manjotho 5
1.2 Procedure
1.2.1 Problem example
Consider the following temperature scale conversion problem example. We are going to draw its IPO
chart, create algorithm and flow chart.
Problem statement: Write a program that receives the temperature in Celsius from the user and
displays the temperature in Fahrenheit and Kelvin scale.
1.2.2 Creating IPO chart and algorithm
Step 01: Create a new blank document in MS Word.
Step 02: Insert a new table of 2 rows 3 columns by going in to Insert Tab>Table
Step 03: Type in basic text in the table.
Input Processing Output
Processing Items:
Algorithm:
Step 04: Identify all the outputs, to the program, from the problem statement. There are two output
of the problem:
 Temperature in Fahrenheit
 Temperature in Kelvin
Step 05: Identify all the inputs, to the program, from the problem statement. There is one input to
the program:
 Temperature in Celsius.
Practical 01: Problem analysis and program design for sequential control flow
6 Computer Programming by Ali Asghar Manjotho
Step 06: Identify all the processing items to be used in solving the problem. The processing items
involve any formula, equation, expression or sequence to be used. There are two formulas to be used:
 F = C * 1.8 + 32
 K = C + 273.15
Step 07: Write down step by step procedure to solve the problem.
 Step 01: Start
 Step 02: Input Celsius c from the user
 Step 03: Calculate Fahrenheit temperature as: f = (c * 1.8) + 32
 Step 04: Calculate Kevin temperature as: k = c + 273.15
 Step 05: Print f and k
 Step 06: End
Step 08: Fill in all the information in IPO chart.
Input Processing Output
• Temperature in
Celsius
Processing Items:
F = C * 1.8 + 32
K = C + 273.15
Algorithm:
Step 01: Start
Step 02: Input Celsius c from the user
Step 03: Calculate Fahrenheit temperature as:
f = (c * 1.8) + 32
Step 04: Calculate Kevin temperature as:
k = c + 273.15
Step 05: Print f and k
Step 06: End
• Temperature in
Fahrenheit
• Temperature in
Kelvin
1.2.3 Creating flow chart
Step 01: Open Edraw Max and create new basic flow chart by going in to Template
Categories>Flowchart>Basic Flowchart. Click the Create button at the right side.
Practical 01: Problem analysis and program design for sequential control flow
Computer Programming by Ali Asghar Manjotho 7
Step 02: Click and drag Start or Terminal symbol from toolbox in to drawing area. Every flow chart
starts with this symbol.
Step 03: Double click the shape to add the text “Start”.
Step 04: Click and drag Data symbol from toolbox in to drawing area.
Step 05: Double click the shape to add the text “Input C”.
Step 06: Click and drag Process symbol from toolbox in to drawing area.
Practical 01: Problem analysis and program design for sequential control flow
8 Computer Programming by Ali Asghar Manjotho
Step 07: Double click the shape to add the text “f = (c * 1.8) + 32”.
Step 08: Click and drag Process symbol from toolbox in to drawing area.
Step 09: Double click the shape to add the text “k = c + 273.15”.
Step 10: Click and drag Data symbol from toolbox in to drawing area.
Step 11: Double click the shape to add the text “Print f, k”.
Step 12: Click and drag Start or Terminal symbol from toolbox in to drawing area. Every flow chart
ends with this symbol.
Practical 01: Problem analysis and program design for sequential control flow
Computer Programming by Ali Asghar Manjotho 9
Step 13: Double click the shape to add the text “End”.
Step 14: Select Right-Angle Connector from the top ribbon bar.
Step 15: Point your cursor over the center of first start symbol. When red lines appear, click over it
(do not leave the click hold your mouse button down), drag your cursor to the center of second
symbol i.e. input box. When the red lines appear over it release the mouse button. Hence you
connected two symbols.
Practical 01: Problem analysis and program design for sequential control flow
10 Computer Programming by Ali Asghar Manjotho
Step 16: Connect rest of the symbols with arrows.
1.3 Problem examples
1.3.1 Area of rectangle
Problem statement: Write a program that accepts the width and the height of a rectangle from the
user and prints the area of the rectangle.
IPO chart and algorithm
Input Processing Output
• Width of rectangle
• Height of rectangle
Processing Items:
area = width * height
Algorithm:
Step 01: Start
Step 02: Input width and height from the user
Step 03: Calculate area as: area = width * height
Step 04: Print area
Step 05: End
• Area of rectangle
Practical 01: Problem analysis and program design for sequential control flow
Computer Programming by Ali Asghar Manjotho 11
Flow chart
1.3.2 Average of three numbers
Problem statement: Write a program that accepts three numbers from the user and displays the
average of the numbers.
IPO chart and algorithm
Input Processing Output
• First number
• Second number
• Third number
Processing Items:
average = (number1 + number2 + number3)/3
Algorithm:
Step 01: Start
Step 02: Input number1, number2 and number3
from the user
Step 03: Calculate average as:
average = (number1 + number2 + number3)/3
Step 04: Print average
Step 05: End
• Average of
numbers
Flow chart
Practical 01: Problem analysis and program design for sequential control flow
12 Computer Programming by Ali Asghar Manjotho
1.3.3 Area and circumference of a circle
Problem statement: Write a program that receives the radius of the circle from the user and displays
the area and circumference of the circle.
IPO chart and algorithm
Input Processing Output
• Radius of circle Processing Items:
area = π * radius^2
circumference = 2 * π * radius
Algorithm:
Step 01: Start
Step 02: Input radius from the user
Step 03: set PI = 3.1415
Step 04: Calculate area as: area = PI * radius^2
Step 05: Calculate circumference as:
circumference = 2 * PI * radius
Step 06: Print area and circumference
Step 07: End
• Area of circle
• Circumference of circle
Flow chart
Practical 01: Problem analysis and program design for sequential control flow
Computer Programming by Ali Asghar Manjotho 13
1.3.4 Buntty, Bubbly and Building
Problem statement: There are two friends Buntty and Bubbly. Buntty is standing at the top of a
vertical building and Bubbly is standing on the ground away from the building. Write a program that
displays the distance of Bubbly from the building after asking the user about the length of the building
and the distance between Buntty and Bubbly.
IPO chart and algorithm
Input Processing Output
• Distance
between Buntty
and Bubbly
• Height of the
Building
Processing Items:
Hyp2 = Base2 + Perp2
Hyp = Distance b/w Buntty and Bubbly
Base = Distance b/w Bubbly and building
Perp = Height of building
Base = √Hyp2 + Perp2
Algorithm:
Step 01: Start
Step 02: Input Dis_Bun_Bub, Height_Bui from the user
Step 03: Calculate Distance b/w Bubbly and building as:
Dis_Bub_Bui = √𝐷𝑖𝑠_𝐵𝑢𝑛_𝐵𝑢𝑏2 + 𝐻𝑒𝑖𝑔ℎ𝑡_𝐵𝑢𝑖2
Step 04: Print Dis_Bub_Bui
Step 05: End
• Distance of
Bubbly from
the building
Flow chart
Practical 01: Problem analysis and program design for sequential control flow
14 Computer Programming by Ali Asghar Manjotho
1.3.5 Reverse a number
Problem statement: Write a program that asks the user to enter a three digit integer number and
displays the reverse number of its.
IPO chart and algorithm
Input Processing Output
• Three digit
integer
number
Processing Items:
549 ==> 945
reverseNum = digit_3 * 100 + digit_2 * 10 + digit_1
Algorithm:
Step 01: Start
Step 02: Input originalNum from the user
Step 03: digit_3 = (originalNum MOD 10)
Step 04: originalNum = ⌊𝑜𝑟𝑖𝑔𝑖𝑛𝑎𝑙𝑁𝑢𝑚 / 10⌋
Step 05: digit_2 = (originalNum MOD 10)
Step 06: originalNum = ⌊𝑜𝑟𝑖𝑔𝑖𝑛𝑎𝑙𝑁𝑢𝑚 / 10⌋
Step 07: digit_1 = originalNum
Step 08: reverseNum = digit_3 * 100 + digit_2 * 10 + digit_1
Step 09: Print reverseNum
Step 10: End
• Reverse number
Flow chart
Practical 01: Problem analysis and program design for sequential control flow
Computer Programming by Ali Asghar Manjotho 15
EXERCISE
1. For each of the following statement write down the flow chart symbol you will use.
A B C D E F
Statement Flow chart symbol
Terminate the process
Set the variable a = 5
Calculate the square of a number
Getting name of the user
Initiate the process
Continue a flow chart on the next page
Displaying the marks of student
Executing another process
Prompting the user
Continue a flow chart on the same page
2. Write down the problem statement for the following flow chart.
Practical 01: Problem analysis and program design for sequential control flow
16 Computer Programming by Ali Asghar Manjotho
3. For each of the following problem statement, create the IPO chart with algorithm and Flow
chart.
Problem Statement 1
Write a computer program that accepts the base and height of a right angle triangle from the user
and displays the area of the triangle.
Problem Statement 2
A person is running in a circular ground. Write a computer program that asks the user to input the
radius of the ground in meters and the number of rounds the person completes. The program should
display the amount of distance travelled by the person in meters.
Problem Statement 3
Write a program that asks the user to enter two integer numbers, stores them in variables num1 and
num2 respectively. The program swaps the values of two variables with each other without using a
third variable and displays the values of both the variables after swapping.
Sample output:
Input: Output:
num1 = 45 num1 = 94
num2 = 94 num2 = 45
Problem Statement 4
Write a program that asks the user to enter a four digit integer number and displays the average of
all the four digits of a number.
Sample output:
Input: Output:
number = 9425 average =
9+4+2+ 5
4
= 5
Problem Statement 5
A person enters the bank and stands in the queue to get his salary. When his turn comes, he requests the
cashier that I need my salary with minimum notes and coins. Write a program for the cashier that first
asks the cashier to enter the salary amount and then displays the number of notes and coins of (Rs. 5000,
Rs. 1000, Rs. 100, Rs. 50, Rs. 20, Rs. 10, Rs. 5, Rs. 2 and Re. 1).

More Related Content

What's hot

C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHESC LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHESHarshJha34
 
Problem Solving Techniques and Introduction to C
Problem Solving Techniques and Introduction to CProblem Solving Techniques and Introduction to C
Problem Solving Techniques and Introduction to CPrabu U
 
more loops lecture by Professor Evan korth
more loops  lecture by Professor Evan korth more loops  lecture by Professor Evan korth
more loops lecture by Professor Evan korth hammad ali
 
Steps for Developing a 'C' program
 Steps for Developing a 'C' program Steps for Developing a 'C' program
Steps for Developing a 'C' programSahithi Naraparaju
 
Architecture Algorithm Definition
Architecture Algorithm DefinitionArchitecture Algorithm Definition
Architecture Algorithm DefinitionGaditek
 
Software develop....
Software develop.... Software develop....
Software develop.... GCWUS
 
Programming aids- Algorithm, Flowchart, Pseudocodes and Decision table
Programming aids- Algorithm, Flowchart, Pseudocodes and Decision tableProgramming aids- Algorithm, Flowchart, Pseudocodes and Decision table
Programming aids- Algorithm, Flowchart, Pseudocodes and Decision tableAnjali Technosoft
 
Ic lecture6 architecture and algo
Ic lecture6 architecture and algoIc lecture6 architecture and algo
Ic lecture6 architecture and algoAttaullahRahimoon
 
Programming fundamentals lecture 1 0f c
Programming fundamentals lecture 1 0f cProgramming fundamentals lecture 1 0f c
Programming fundamentals lecture 1 0f cRaja Hamid
 
Csc 102 lecture note(introduction to problem solving)
Csc 102 lecture note(introduction to problem solving)Csc 102 lecture note(introduction to problem solving)
Csc 102 lecture note(introduction to problem solving)Christopher Chizoba
 
Algorithm and Flowcharts
Algorithm and FlowchartsAlgorithm and Flowcharts
Algorithm and FlowchartsSURBHI SAROHA
 
Algorithm & flowchart
Algorithm & flowchartAlgorithm & flowchart
Algorithm & flowchartsaurabh sen sky
 
1 introduction to problem solving and programming
1 introduction to problem solving and programming1 introduction to problem solving and programming
1 introduction to problem solving and programmingRheigh Henley Calderon
 
Algorithm and flowchart2010
Algorithm and flowchart2010Algorithm and flowchart2010
Algorithm and flowchart2010Jordan Delacruz
 
Programming flowcharts for C Language
Programming flowcharts for C LanguageProgramming flowcharts for C Language
Programming flowcharts for C LanguageAryan Ajmer
 
Unit 1. Problem Solving with Computer
Unit 1. Problem Solving with Computer   Unit 1. Problem Solving with Computer
Unit 1. Problem Solving with Computer Ashim Lamichhane
 
Algorithm and flowchart
Algorithm and flowchart Algorithm and flowchart
Algorithm and flowchart Shivam Sharma
 
Flowchart and algorithm
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithmDHANIK VIKRANT
 

What's hot (20)

C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHESC LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
 
Problem Solving Techniques and Introduction to C
Problem Solving Techniques and Introduction to CProblem Solving Techniques and Introduction to C
Problem Solving Techniques and Introduction to C
 
more loops lecture by Professor Evan korth
more loops  lecture by Professor Evan korth more loops  lecture by Professor Evan korth
more loops lecture by Professor Evan korth
 
Steps for Developing a 'C' program
 Steps for Developing a 'C' program Steps for Developing a 'C' program
Steps for Developing a 'C' program
 
Architecture Algorithm Definition
Architecture Algorithm DefinitionArchitecture Algorithm Definition
Architecture Algorithm Definition
 
Software develop....
Software develop.... Software develop....
Software develop....
 
Programming aids- Algorithm, Flowchart, Pseudocodes and Decision table
Programming aids- Algorithm, Flowchart, Pseudocodes and Decision tableProgramming aids- Algorithm, Flowchart, Pseudocodes and Decision table
Programming aids- Algorithm, Flowchart, Pseudocodes and Decision table
 
Ic lecture6 architecture and algo
Ic lecture6 architecture and algoIc lecture6 architecture and algo
Ic lecture6 architecture and algo
 
Programming fundamentals lecture 1 0f c
Programming fundamentals lecture 1 0f cProgramming fundamentals lecture 1 0f c
Programming fundamentals lecture 1 0f c
 
Csc 102 lecture note(introduction to problem solving)
Csc 102 lecture note(introduction to problem solving)Csc 102 lecture note(introduction to problem solving)
Csc 102 lecture note(introduction to problem solving)
 
Chapter 02 - Problem Solving
Chapter 02 - Problem SolvingChapter 02 - Problem Solving
Chapter 02 - Problem Solving
 
Introduction to problem solving in C
Introduction to problem solving in CIntroduction to problem solving in C
Introduction to problem solving in C
 
Algorithm and Flowcharts
Algorithm and FlowchartsAlgorithm and Flowcharts
Algorithm and Flowcharts
 
Algorithm & flowchart
Algorithm & flowchartAlgorithm & flowchart
Algorithm & flowchart
 
1 introduction to problem solving and programming
1 introduction to problem solving and programming1 introduction to problem solving and programming
1 introduction to problem solving and programming
 
Algorithm and flowchart2010
Algorithm and flowchart2010Algorithm and flowchart2010
Algorithm and flowchart2010
 
Programming flowcharts for C Language
Programming flowcharts for C LanguageProgramming flowcharts for C Language
Programming flowcharts for C Language
 
Unit 1. Problem Solving with Computer
Unit 1. Problem Solving with Computer   Unit 1. Problem Solving with Computer
Unit 1. Problem Solving with Computer
 
Algorithm and flowchart
Algorithm and flowchart Algorithm and flowchart
Algorithm and flowchart
 
Flowchart and algorithm
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithm
 

Similar to Practical 01 (detailed)

Algorithm for computational problematic sit
Algorithm for computational problematic sitAlgorithm for computational problematic sit
Algorithm for computational problematic sitSaurabh846965
 
Algorithm types performance steps working
Algorithm types performance steps workingAlgorithm types performance steps working
Algorithm types performance steps workingSaurabh846965
 
Programming_Lecture_1.pptx
Programming_Lecture_1.pptxProgramming_Lecture_1.pptx
Programming_Lecture_1.pptxshoaibkhan716300
 
AOA Week 01.ppt
AOA Week 01.pptAOA Week 01.ppt
AOA Week 01.pptINAM352782
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchartSachin Goyani
 
Week1 programming challenges
Week1 programming challengesWeek1 programming challenges
Week1 programming challengesDhanu Srikar
 
Algorithms notes 2 tutorials duniya
Algorithms notes 2   tutorials duniyaAlgorithms notes 2   tutorials duniya
Algorithms notes 2 tutorials duniyaTutorialsDuniya.com
 
9th Comp Ch 1 LQ.pdf
9th Comp Ch 1 LQ.pdf9th Comp Ch 1 LQ.pdf
9th Comp Ch 1 LQ.pdfNaeem Mughal
 
problem solving and design By ZAK
problem solving and design By ZAKproblem solving and design By ZAK
problem solving and design By ZAKTabsheer Hasan
 
Logic Development and Algorithm.
Logic Development and Algorithm.Logic Development and Algorithm.
Logic Development and Algorithm.NandiniSidana
 
Ch1 principles of software development
Ch1 principles of software developmentCh1 principles of software development
Ch1 principles of software developmentHattori Sidek
 
Chapter 2(1)
Chapter 2(1)Chapter 2(1)
Chapter 2(1)TejaswiB4
 
L1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdfL1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdfMMRF2
 

Similar to Practical 01 (detailed) (20)

Module 1 python.pptx
Module 1 python.pptxModule 1 python.pptx
Module 1 python.pptx
 
Algorithm for computational problematic sit
Algorithm for computational problematic sitAlgorithm for computational problematic sit
Algorithm for computational problematic sit
 
Algorithm.pdf
Algorithm.pdfAlgorithm.pdf
Algorithm.pdf
 
Problem solving methodology
Problem solving methodologyProblem solving methodology
Problem solving methodology
 
PPS_Unit 1.pptx
PPS_Unit 1.pptxPPS_Unit 1.pptx
PPS_Unit 1.pptx
 
Algorithm types performance steps working
Algorithm types performance steps workingAlgorithm types performance steps working
Algorithm types performance steps working
 
Introduction.pptx
Introduction.pptxIntroduction.pptx
Introduction.pptx
 
Programming_Lecture_1.pptx
Programming_Lecture_1.pptxProgramming_Lecture_1.pptx
Programming_Lecture_1.pptx
 
AOA Week 01.ppt
AOA Week 01.pptAOA Week 01.ppt
AOA Week 01.ppt
 
Algo and flowchart
Algo and flowchartAlgo and flowchart
Algo and flowchart
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Fundamentals of Programming Chapter 3
Fundamentals of Programming Chapter 3Fundamentals of Programming Chapter 3
Fundamentals of Programming Chapter 3
 
Week1 programming challenges
Week1 programming challengesWeek1 programming challenges
Week1 programming challenges
 
Algorithms notes 2 tutorials duniya
Algorithms notes 2   tutorials duniyaAlgorithms notes 2   tutorials duniya
Algorithms notes 2 tutorials duniya
 
9th Comp Ch 1 LQ.pdf
9th Comp Ch 1 LQ.pdf9th Comp Ch 1 LQ.pdf
9th Comp Ch 1 LQ.pdf
 
problem solving and design By ZAK
problem solving and design By ZAKproblem solving and design By ZAK
problem solving and design By ZAK
 
Logic Development and Algorithm.
Logic Development and Algorithm.Logic Development and Algorithm.
Logic Development and Algorithm.
 
Ch1 principles of software development
Ch1 principles of software developmentCh1 principles of software development
Ch1 principles of software development
 
Chapter 2(1)
Chapter 2(1)Chapter 2(1)
Chapter 2(1)
 
L1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdfL1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdf
 

More from Muhammadalizardari (14)

Effective communication-presentation
Effective communication-presentationEffective communication-presentation
Effective communication-presentation
 
Computer graphics workbook
Computer graphics workbookComputer graphics workbook
Computer graphics workbook
 
Ppi 8255
Ppi 8255Ppi 8255
Ppi 8255
 
8085 instruction-set
8085 instruction-set8085 instruction-set
8085 instruction-set
 
Dld
DldDld
Dld
 
Subsections
SubsectionsSubsections
Subsections
 
Need based application
Need based applicationNeed based application
Need based application
 
Making things electronics
Making things electronicsMaking things electronics
Making things electronics
 
Intro to electronics
Intro to electronicsIntro to electronics
Intro to electronics
 
Ee intro electronics
Ee intro electronicsEe intro electronics
Ee intro electronics
 
Definition of electronics
Definition of electronicsDefinition of electronics
Definition of electronics
 
F16 cs61 li-fi
F16 cs61   li-fiF16 cs61   li-fi
F16 cs61 li-fi
 
F16 cs15 free lancing (1)
F16 cs15   free lancing (1)F16 cs15   free lancing (1)
F16 cs15 free lancing (1)
 
F16 cs61 cryptography
F16 cs61   cryptographyF16 cs61   cryptography
F16 cs61 cryptography
 

Recently uploaded

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 

Recently uploaded (20)

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 

Practical 01 (detailed)

  • 1. Computer Programming by Ali Asghar Manjotho 1 Practical 01 Problem analysis and program design for sequential control flow Objectives  Understand the basic concepts involved in solving computational problems.  Analyzing and designing programs for sequential logic.  To get familiar with and be able to create IPO chart for various problems.  To get familiar with and be able to create algorithms to solve various problems.  To get familiar with and be able to translate algorithms in to flow charts. Tools  Edraw Max (Version: 6.8 or 7.2)  Microsoft Word (Version: 2007, 2010 or 2013) Keywords: Problem solving, computational problems, sequential logic, IPO chart, algorithm, flow chart. Duration: 03 hours 1.1 Introduction 1.1.1 Problem solving in everyday life People make decisions every day to solve problems that affect their lives. The problems may be as unimportant as what to watch on television or as important as choosing a new profession. If a bad decision is made, time and resources are wasted, so it’s important that people know how to make decisions well. There are six steps to follow to ensure the best decision: 1. Identify the problem. The first step towards solving a problem is to identify the problem. If you don’t know what the problem is, you cannot solve it. In a classroom situation, most problems have been identified for you and given to you in the form of written assignments or problems out of a book. However, when you are doing problem solving outside the classroom, you need to make sure you identify the problem before you start solving it. 2. Understand the problem. You must understand what is involved in the problem before you can continue toward the solution. You cannot solve a problem if you do not know the subject. For example, to solve a problem involving average of numbers, you must know how to calculate average; to solve a problem of trigonometry, you must know trigonometry. Evaluate the solution List instruction to solve problem Select the best solution Identify alternative solutions Understand the problem Identify the problem
  • 2. Practical 01: Problem analysis and program design for sequential control flow 2 Computer Programming by Ali Asghar Manjotho 3. Identify alternative solutions. A single problem can be solved in many different ways. Identify and list all the possible solutions to the problem. For example there are multiple ways to sort the numbers as: Insertion sort, Selection sort or Bubble sort. 4. Select the best solution. Analyze and identify the pros and cons of every alternative solution. Choose the solution that is optimal and best matches with your requirements. For example out of all the sorting options you choose bubble sort as your best solution. 5. List instructions to solve problem. Write down general step by step procedure to solve the problem. For example to solve problem of calculating average of three numbers:  Step 01 : Ask numbers a, b, and c from the user  Step 02 : Add a, b, c and store result in sum  Step 03 : Divide sum by 3 and store result in avg  Step 04 : Display avg 6. Evaluate the solution. Finally evaluate and test the solution, means to check its result to see if it is correct and satisfies the needs. For example, when a person needs a pen to write a letter, buying him marker may be a correct solution, but it may not be very satisfactory. If the result is either incorrect or unsatisfactory, then the problem solver must review the list of instructions to see that they are correct or start the process all over again. If any of these six steps are not completed well, the results may be less than desired. Most people use them without even knowing it. 1.1.2 Sequential control flow Sequential control flow also referred to as sequential logic is one of the order in which the program instructions are executed. A program is usually composed of multiple instructions which are to be executed by the computer. It is the default order of program execution. In sequential logic:  A program starts at first instruction and all the instructions are executed in a sequence of one after another.  No any instruction is skipped out of the execution.  Order of execution is not violated (all instruction are executed in sequence e.g. Instruction 1 then 2, followed by 3 and so on). 1.1.3 Problem analysis tools Problem analysis is a set of activities that increase the designer’s understanding of a problem, in order to have a better solution. Problem analysis tools help you analyze the problem to have a clear picture of the problem. They are used to conduct postmortem of a problem. Three of the problem analysis tools used in this practical are:
  • 3. Practical 01: Problem analysis and program design for sequential control flow Computer Programming by Ali Asghar Manjotho 3 1.1.3.1 IPO (Input Process Output) chart IPO stands for Input Process Output. It performs the analysis by identifying the inputs, processing items and outputs of a given problem. It can be represented by the following chart: Input Processing Output Processing Items: Algorithm: The input section specifies all the inputs to the problem. The input may be given by the user from input devices like, keyboard, mouse, scanner etc. The input may also come as the contents of a file. The input may come from the network or Internet. The output section specifies all the outcomes of the problem. The output may be in the form of the presenting the results on the monitor screen, printer or any other output device. The output may also be stored in a file. The output may be redirected to network or Internet. The processing section specifies two things: processing items and algorithm. The processing items involve any formula or equation to be used while processing. The algorithm is the step by step processing procedure to solve that task. 1.1.3.2 Algorithm Algorithm is the representation of a solution to a problem. It is step by step procedure to solve a given problem. An algorithm contains finite number of instructions in order to solve a problem. For example, calculating the average of three numbers. Step 01: Start Step 02: Input number1, number2 and number3 from the user Step 03: Calculate average as: average = (number1 + number2 + number3)/3 Step 04: Print average Step 05: End
  • 4. Practical 01: Problem analysis and program design for sequential control flow 4 Computer Programming by Ali Asghar Manjotho 1.1.3.3 Flow chart Flow chart is the pictorial representation of a process or an algorithm. It uses symbols (boxes of different shapes) to represent each step of an algorithm. All the symbols are then connected with arrows to show the flow of the process. Following is the list of some commonly used flow chart symbols: Symbol Name Meaning Terminal (Oval) Indicates the beginning and end points of an algorithm. Process (Rectangle) Shows an instruction other than input, output or selection. Input-Output (Parallelogram) Shows an input or output instruction. Decision (Diamond) Shows any point in the process where decision is to be made. On-Page Connector Continues and connects the flowchart on the same page. Off-Page Connector Continues and connects the flowchart on another page. Sub-Process Denotes movement to another process and hence a new flowchart. Arrows Connects symbols and shows flow of the process or algorithm.
  • 5. Practical 01: Problem analysis and program design for sequential control flow Computer Programming by Ali Asghar Manjotho 5 1.2 Procedure 1.2.1 Problem example Consider the following temperature scale conversion problem example. We are going to draw its IPO chart, create algorithm and flow chart. Problem statement: Write a program that receives the temperature in Celsius from the user and displays the temperature in Fahrenheit and Kelvin scale. 1.2.2 Creating IPO chart and algorithm Step 01: Create a new blank document in MS Word. Step 02: Insert a new table of 2 rows 3 columns by going in to Insert Tab>Table Step 03: Type in basic text in the table. Input Processing Output Processing Items: Algorithm: Step 04: Identify all the outputs, to the program, from the problem statement. There are two output of the problem:  Temperature in Fahrenheit  Temperature in Kelvin Step 05: Identify all the inputs, to the program, from the problem statement. There is one input to the program:  Temperature in Celsius.
  • 6. Practical 01: Problem analysis and program design for sequential control flow 6 Computer Programming by Ali Asghar Manjotho Step 06: Identify all the processing items to be used in solving the problem. The processing items involve any formula, equation, expression or sequence to be used. There are two formulas to be used:  F = C * 1.8 + 32  K = C + 273.15 Step 07: Write down step by step procedure to solve the problem.  Step 01: Start  Step 02: Input Celsius c from the user  Step 03: Calculate Fahrenheit temperature as: f = (c * 1.8) + 32  Step 04: Calculate Kevin temperature as: k = c + 273.15  Step 05: Print f and k  Step 06: End Step 08: Fill in all the information in IPO chart. Input Processing Output • Temperature in Celsius Processing Items: F = C * 1.8 + 32 K = C + 273.15 Algorithm: Step 01: Start Step 02: Input Celsius c from the user Step 03: Calculate Fahrenheit temperature as: f = (c * 1.8) + 32 Step 04: Calculate Kevin temperature as: k = c + 273.15 Step 05: Print f and k Step 06: End • Temperature in Fahrenheit • Temperature in Kelvin 1.2.3 Creating flow chart Step 01: Open Edraw Max and create new basic flow chart by going in to Template Categories>Flowchart>Basic Flowchart. Click the Create button at the right side.
  • 7. Practical 01: Problem analysis and program design for sequential control flow Computer Programming by Ali Asghar Manjotho 7 Step 02: Click and drag Start or Terminal symbol from toolbox in to drawing area. Every flow chart starts with this symbol. Step 03: Double click the shape to add the text “Start”. Step 04: Click and drag Data symbol from toolbox in to drawing area. Step 05: Double click the shape to add the text “Input C”. Step 06: Click and drag Process symbol from toolbox in to drawing area.
  • 8. Practical 01: Problem analysis and program design for sequential control flow 8 Computer Programming by Ali Asghar Manjotho Step 07: Double click the shape to add the text “f = (c * 1.8) + 32”. Step 08: Click and drag Process symbol from toolbox in to drawing area. Step 09: Double click the shape to add the text “k = c + 273.15”. Step 10: Click and drag Data symbol from toolbox in to drawing area. Step 11: Double click the shape to add the text “Print f, k”. Step 12: Click and drag Start or Terminal symbol from toolbox in to drawing area. Every flow chart ends with this symbol.
  • 9. Practical 01: Problem analysis and program design for sequential control flow Computer Programming by Ali Asghar Manjotho 9 Step 13: Double click the shape to add the text “End”. Step 14: Select Right-Angle Connector from the top ribbon bar. Step 15: Point your cursor over the center of first start symbol. When red lines appear, click over it (do not leave the click hold your mouse button down), drag your cursor to the center of second symbol i.e. input box. When the red lines appear over it release the mouse button. Hence you connected two symbols.
  • 10. Practical 01: Problem analysis and program design for sequential control flow 10 Computer Programming by Ali Asghar Manjotho Step 16: Connect rest of the symbols with arrows. 1.3 Problem examples 1.3.1 Area of rectangle Problem statement: Write a program that accepts the width and the height of a rectangle from the user and prints the area of the rectangle. IPO chart and algorithm Input Processing Output • Width of rectangle • Height of rectangle Processing Items: area = width * height Algorithm: Step 01: Start Step 02: Input width and height from the user Step 03: Calculate area as: area = width * height Step 04: Print area Step 05: End • Area of rectangle
  • 11. Practical 01: Problem analysis and program design for sequential control flow Computer Programming by Ali Asghar Manjotho 11 Flow chart 1.3.2 Average of three numbers Problem statement: Write a program that accepts three numbers from the user and displays the average of the numbers. IPO chart and algorithm Input Processing Output • First number • Second number • Third number Processing Items: average = (number1 + number2 + number3)/3 Algorithm: Step 01: Start Step 02: Input number1, number2 and number3 from the user Step 03: Calculate average as: average = (number1 + number2 + number3)/3 Step 04: Print average Step 05: End • Average of numbers Flow chart
  • 12. Practical 01: Problem analysis and program design for sequential control flow 12 Computer Programming by Ali Asghar Manjotho 1.3.3 Area and circumference of a circle Problem statement: Write a program that receives the radius of the circle from the user and displays the area and circumference of the circle. IPO chart and algorithm Input Processing Output • Radius of circle Processing Items: area = π * radius^2 circumference = 2 * π * radius Algorithm: Step 01: Start Step 02: Input radius from the user Step 03: set PI = 3.1415 Step 04: Calculate area as: area = PI * radius^2 Step 05: Calculate circumference as: circumference = 2 * PI * radius Step 06: Print area and circumference Step 07: End • Area of circle • Circumference of circle Flow chart
  • 13. Practical 01: Problem analysis and program design for sequential control flow Computer Programming by Ali Asghar Manjotho 13 1.3.4 Buntty, Bubbly and Building Problem statement: There are two friends Buntty and Bubbly. Buntty is standing at the top of a vertical building and Bubbly is standing on the ground away from the building. Write a program that displays the distance of Bubbly from the building after asking the user about the length of the building and the distance between Buntty and Bubbly. IPO chart and algorithm Input Processing Output • Distance between Buntty and Bubbly • Height of the Building Processing Items: Hyp2 = Base2 + Perp2 Hyp = Distance b/w Buntty and Bubbly Base = Distance b/w Bubbly and building Perp = Height of building Base = √Hyp2 + Perp2 Algorithm: Step 01: Start Step 02: Input Dis_Bun_Bub, Height_Bui from the user Step 03: Calculate Distance b/w Bubbly and building as: Dis_Bub_Bui = √𝐷𝑖𝑠_𝐵𝑢𝑛_𝐵𝑢𝑏2 + 𝐻𝑒𝑖𝑔ℎ𝑡_𝐵𝑢𝑖2 Step 04: Print Dis_Bub_Bui Step 05: End • Distance of Bubbly from the building Flow chart
  • 14. Practical 01: Problem analysis and program design for sequential control flow 14 Computer Programming by Ali Asghar Manjotho 1.3.5 Reverse a number Problem statement: Write a program that asks the user to enter a three digit integer number and displays the reverse number of its. IPO chart and algorithm Input Processing Output • Three digit integer number Processing Items: 549 ==> 945 reverseNum = digit_3 * 100 + digit_2 * 10 + digit_1 Algorithm: Step 01: Start Step 02: Input originalNum from the user Step 03: digit_3 = (originalNum MOD 10) Step 04: originalNum = ⌊𝑜𝑟𝑖𝑔𝑖𝑛𝑎𝑙𝑁𝑢𝑚 / 10⌋ Step 05: digit_2 = (originalNum MOD 10) Step 06: originalNum = ⌊𝑜𝑟𝑖𝑔𝑖𝑛𝑎𝑙𝑁𝑢𝑚 / 10⌋ Step 07: digit_1 = originalNum Step 08: reverseNum = digit_3 * 100 + digit_2 * 10 + digit_1 Step 09: Print reverseNum Step 10: End • Reverse number Flow chart
  • 15. Practical 01: Problem analysis and program design for sequential control flow Computer Programming by Ali Asghar Manjotho 15 EXERCISE 1. For each of the following statement write down the flow chart symbol you will use. A B C D E F Statement Flow chart symbol Terminate the process Set the variable a = 5 Calculate the square of a number Getting name of the user Initiate the process Continue a flow chart on the next page Displaying the marks of student Executing another process Prompting the user Continue a flow chart on the same page 2. Write down the problem statement for the following flow chart.
  • 16. Practical 01: Problem analysis and program design for sequential control flow 16 Computer Programming by Ali Asghar Manjotho 3. For each of the following problem statement, create the IPO chart with algorithm and Flow chart. Problem Statement 1 Write a computer program that accepts the base and height of a right angle triangle from the user and displays the area of the triangle. Problem Statement 2 A person is running in a circular ground. Write a computer program that asks the user to input the radius of the ground in meters and the number of rounds the person completes. The program should display the amount of distance travelled by the person in meters. Problem Statement 3 Write a program that asks the user to enter two integer numbers, stores them in variables num1 and num2 respectively. The program swaps the values of two variables with each other without using a third variable and displays the values of both the variables after swapping. Sample output: Input: Output: num1 = 45 num1 = 94 num2 = 94 num2 = 45 Problem Statement 4 Write a program that asks the user to enter a four digit integer number and displays the average of all the four digits of a number. Sample output: Input: Output: number = 9425 average = 9+4+2+ 5 4 = 5 Problem Statement 5 A person enters the bank and stands in the queue to get his salary. When his turn comes, he requests the cashier that I need my salary with minimum notes and coins. Write a program for the cashier that first asks the cashier to enter the salary amount and then displays the number of notes and coins of (Rs. 5000, Rs. 1000, Rs. 100, Rs. 50, Rs. 20, Rs. 10, Rs. 5, Rs. 2 and Re. 1).