0% found this document useful (0 votes)
20 views3 pages

CH - 4 Intro To Problem Solving

Chapter 4 introduces problem-solving steps including analyzing the problem, developing an algorithm, coding, and testing. It explains algorithms, pseudocode, and flowcharts as methods for representing and solving problems, along with examples for summing numbers, checking odd/even, and calculating averages. The chapter also covers flow control methods such as sequences, selection, and repetition, emphasizing the importance of decomposition in problem-solving.

Uploaded by

salirnaqvi2006
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views3 pages

CH - 4 Intro To Problem Solving

Chapter 4 introduces problem-solving steps including analyzing the problem, developing an algorithm, coding, and testing. It explains algorithms, pseudocode, and flowcharts as methods for representing and solving problems, along with examples for summing numbers, checking odd/even, and calculating averages. The chapter also covers flow control methods such as sequences, selection, and repetition, emphasizing the importance of decomposition in problem-solving.

Uploaded by

salirnaqvi2006
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Chapter-4

INTRODUCTION TO PROBLEM SOLVING

Steps for problem solving:


Step 1 : Analysing the problem
Step 2: Developing an algorithm
Step 3 : Coding
Step4 : Testing and Debugging

Algorithm
A set of exact steps which when followed, solve the problem or accomplish the required task or it is a
step by step procedure to perform an operation which will lead to the desired result, if followed correctly.

Pseudocode
➢ It is another way of representing an algorithm.
➢ It is considered as an non formal language that helps programmer to write algorithm.

Flowchart( Visual representation of Algorithm)


A Flowchart is a type of diagram that represents the algorithm graphically using different shapes,
in an order connected by arrows.
Each shape represent a step of solution or process and arrow represents the order or link among
the steps.
Q1. Write an algorithm to display the sum of two numbers entered by users, using pseudocode and
flowchart.
Flowchart:
A. Pseudocode:
INPUT NUM1
INPUT NUM2
COMPUTE RESULT = NUM1 + NUM2
PRINT RESULT

Q2. Write an algorithm to check whether a number is odd or even.

• Input: Any number


• Process: Check whether the number is even or not Flowchart:
• Output: Message “Even” or “Odd”
Pseudocode of the algorithm can be written as follows:
PRINT "Enter the Number"
INPUT number
IF number MOD 2 == 0 THEN
PRINT "Number is Even"
ELSE
PRINT "Number is Odd”

Q3. Write pseudocode and draw a flowchart to accept 5 numbers and find their average.
Pseudocode will be as follows: Flowchart:
Step 1: SET count = 0, sum = 0
Step 2: WHILE count <5 , REPEAT steps 3 to 5
Step 3: INPUT a number to num
Step 4: sum = sum + num
Step 5: count = count + 1
Step 6: COMPUTE average = sum/5
Step 7: PRINT average
Flow of Control
The flow of control depicts flow of events as represented in flow chart.
The events can flow in any of the following ways:
1. Sequences:
An Algorithm where all steps are executed one after the other are said to be execute in sequence.
Eg> refer Q 1

2. Selection:
Any one of the alternative is selected based on outcomes of a condition .
Conditionals are used to check possibilities.
The program checks one or more conditions and perform operations depending on True or False
value of condition.
Note : In programming languages True or False conditions are written using if-else block in actual
program.
“Otherwise” is used as ‘Else keyword’. Eg. Flowchart Q3
3. Repetition( Loop Iteration):
In programming repetition is known as loop or iteration.
A loop in an algorithm means execution of some algorithm statements repeatedly until some
specified condition is satisfied. Eg. Q 3

Decomposition
The basic idea of solving a problem by decomposition is to decompose or breakdown a complex
problem into smallest subproblem.

***************************

You might also like