Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 17

Unit 4

Problem Solving
Problem statement & its parts.
It is the initial stage. It’s very important to
understand the problem before the
programmer starts working on the solution.
It has three parts:
1.What is given: It is called the input.
2.Processing requirement: It deals with the
operations/calculations which are carried out
to produce the output.
3.What is required: It is called the output

Input First number


Second number

Operation/
Addition
calculation

Answer
Output
Program: A program is a list of instructions that tell a
computer what to do.

Programmer: A programmer is a person who:


1.Designs (algorithm , flowchart)
2.Writes the program in computer by using computer
language.
3.Tests the programs and removes the errors.
Algorithm:
 It is a stepwise procedure to solve a
problem.
 It is an early stage to solve a problem.
 It uses words to describe the steps required
to solve the problem.
Problem: Multiply any 2
Algorithm
numbers

Step-1 Start
Step-2 Input first number a
Step-3 Input second number b
Step-4 product=a*b
Step-5 Print product
Step-6 Stop
For Algorithm
• Inputs needed
• Processing to be completed
• Decisions to be taken
• Outputs to be provided
Steps required to write an algorithm:
Define the Input. For example to calculate area of a
rectangle, we need length and breadth as an input.
Define the variables. The variables are used to hold the
values. For example L for length and B for breadth.
Write the operation. We use the variables to do
calculation and store the answer in a new variable. For
example To find area of rectangle the operation will be
Area=L * B
Output. It is the result of operation. For example the
variable Area is having the result.
Make a jam and butter sandwich
Step 1-Start
Step 2 Input: JAM, Butter,Knife,Plate
Step 3 Process:
a.Put two slices of bread on plate.
b.Using the knife,spread butter on one side
c.Using the knife spread jam on the other side
d.Put the two slices together.
e.Repeat the procedure if you want more
sandwiches.
Step 4 Output: Jam and Butter Sandwiches
Step 5 Stop
Write an algorithm to find the sum of two
numbers.
Algorithm
Step-1 Start
Step-2 Input first number A
Step-3 Input second number B
Step-4 SUM = A + B
Step-5 Print SUM
Step-6 Stop
Write an algorithm to display the larger
number out of given 2 unequal
numbers.

Step-1 Start
Step-2 Input two numbers a , b
Step-3 IF a > b THEN print largest is a
ELSE print largest is b
Step-4 Stop
 
Flowchart:
• It is a diagram that represents an algorithm or the
steps to solve the problem.
• It shows the flow of data.
• It uses symbols, shapes and arrows to show the
steps to solve a problem.
• It shows the operations performed within the
program.
 
Note: Algorithms and flowcharts are two different
tools used for creating new programs, especially
in computer programming.
Difference between algorithm and flowchart
Algorithm Flow Chart
It uses words to describe the It uses symbols, shapes and
steps to solve a problem. arrows to show the steps to
solve a problem.

Step-1 Start
Step-2 Input first number a
Step-3 Input second number b
Step-4 product=a*b
Step-5 Print product
Step-6 Stop
Standard flowchart symbols and write their names.
Use in flowchart Name Symbol
   
Represent the start and end Oval
   
 
Represent Input and output Parallelogram
 
   
Represents a process or operation Rectangle
   

Represent the direction of flow of data Flow line

   
Represent decision Diamond
   
Write an Algorithm and Draw a flowchart to find the
product of given 2 numbers.

Step-1 Start
Step-2 Input first numbers a
Step-2 Input second numbers b
Step-3 product=a*b
Step-5 Print product
Step-6 Stop
Fill in the blanks.

1.A problem ______ a clear description of an issue.

2.A program is a set of sequenced _____ for a computer to


perform a task.

3.A _____is a person who designs, writes and tests the


computer programs.

4.______ is a stepwise procedure to solve a problem.

5.A ________ is a graphical representation of a problem


solution.
 
True or False
1.What is given is called the input. T/F

2.What is required is called the output. T/F

3.A user needs to write a problem statement after


solving the problem. F/T

4.A program is a set of sequenced instructions for a


computer to perform a task. T/F

5.Oval represents a process. F/T

You might also like