Chapter 5 - Introduction to Problem Solving
Chapter 5 - Introduction to Problem Solving
Introduction to
Problem Solving
In This Chapter
5.1 Introduction
5.2 Problem Solving Cycle
5.1 INTRODUCTION
There is a famous quote by Steve Jobs, which says, "Everyone in this country should learn to
program a computer, because it teaches you to think".
This quote itself is proof-enough to say that in order to program a solution for a problem, you
should think in a specific way. And this is what we are going to talk about in this chapter.
In this chapter, you will learn about problem solving, i., analysing a problem, designing
algorithms using tools like flowcharts and pseudocode and problem solving using
decomposition. So, let us begin.
109
110 cOMPUTER SCIENCE WITH
PYTHON
5.2 PROBLEM SOLVING CYCLE
Programs are not quick creations. In order to create efficient and effective programs, youh
should
adopt a proper problem solving methodology and use appropriate techniques. In fact, prah.
solving methods follow a cycle - the problem solving cycle. In the coming lines, we are eoin bblem
discuss the same. oing to
Broadly problem solving requires four main steps
1. Identify and the problem.
analyse
2. Find its solution and Develop algorithm of the solution.
3. Code the solution in a
programming language.
4. Test and Debug the coded solution. 1
Analyse the
2
And finally implement and maintain it. problem Find solution
and Develop
The above mentioned steps are four major steps in a Algorithm
problem solving cycle. Each step contains many
sub-steps. Let us talk about these sub-steps in order to
Perform Testing
understand the problem solving cycle. The aim of a and
problem solving cycle is to create a working program Debugging
Coding of the
for the solution. solution
2. Analyze the problem Problem analysis is very important as the outcome of this will
convert to the success of final solution. While analyzing
identify processing components
identify the relationships among processing components.
3. Think of As per the problem analysis, think of
possible solutions by trying ths
possible solutions think of different ideas for solutions
check your ideas for aptness
finally, zero on most appropriate solution.
Follow Modular Many small logically related modules.or functions must be P
approach while ferred over a big problem. It is called Modular approach whered
designing miost divide a big program into many smaller and more managea
appropriate solulion understandable modules.
Design the final program by
deciding step by step solution
breaking down solution into simple steps.
tions
effectiveness.
Test and Debug your and debugging
7. Testing is the process of finding errors in a program
program is the process of correcting errors found during the testing process.
Thus, this phase involves:
finding errors in it.
rectifying the errors.
Documentation is intended to allow another person or the prog
8. Complete your rammer at later date, to understand the program. Documentation
documentation
might also consist of a detailed description of what the program
does and how to use the program.
After testing and documentation, implement your program for
9. lmplement your
code actual use on site. Now, the real users can use your programs.
10. Maintain your Maintaining programs involves modifying the programs to remove
involves
Dividing a task into a sequence of subtasks.
Identifying elements or parts of a complex system.
Big problem Break down into
smaller, logical parts
Part 2 of problem
Part 1 of problem
Further break down
Further break down into even smaller
into even smaller,
ogical parts
logical parts Sub-problem 2 Sub-problem 3 Sub-problem 4
Sub-problem 1
112 COMPUTER SCIENCE WITH PYTHONV
X
(O
2
C
114 COMPUTER SCIENCE WITH PYTHON
These are
Each operation
i.e., it must be
clearly defined what should be done. For instance, 'x
must be definite =6/0,
'add 3 or 8 to a' are not
permitted as these operations are not clearly defined.
Each operation i.e., each step must þe such that it can be done
must be effective
finite amount of time. For using pencil and paper in a
example, arithmetic on integers is effective
operation, whereas arithmetic on real numbers is not since some values
be expressible only may
by an infinitely long decimal expansion
Each operation i.e., the algorithm should terminate after a finite number of
must be finite operations.
Thus, we can
say that a
good algorithm must have
sub-section. characteristics as listed in the following
Characteristics of a Good Algorithm
In order to be an effective
algorithm, an algorithm must have the following characteristics
1. Precision. An algorithm should be
precise, i.e., its steps should be precisely defined.
2.
Uniquenes. Every step should uniquely contribute to the
unique and it is only dependent on the algorithm.
result of a step is It means that the
5.3.1 Flowcharts
A flowchart is a pictorial representation of step by step solution of a problem.
A flowchart not only pictorially depicts the sequence in which
FLOWCHART
instructions are carried out in an algorithm but also is used as
A flowchart.is a pictorial
an aid in developing algorithms. One must be familiar with representation of step by step
such an important tool used in programming. This section solution of a problem.
briefly discusses the technique of flow charting.
There are various flowchart symbols that carry different messages and are used for different
purposes. These symbols are shown below:
Input/Output
Annotation
Processing
Decision Box
O Connector.
Following section illustrates the working and use of tlow charts along with algorithm
development.
Writing Algorithms
0 write algorithms, such a language should be used that is close enough to the programming
language(s) (in which the programs are to be written) so that a hand translation is relatively
Easy to accomplish. Thus, we have chosen a language for algorithms that resembles our
Selection/Conditional Statements
A conditional
statement in an algorithm takes the following form:
i fcondition ifcondition:
statement # block1 OR statement # block 1
else
s2 # block 2
There may be one or more if-then-else statements
embedded in another if-then-else statement.
Figure 5.1 depicts conditional statements pictorially.
true
Condition Condition
true
false or
false
No
St represents the set of statements to be repeated for
each item in the sequence. When the statements block Statement block
Stop
while loop
while condition: Condition False
processing
St # block of statements
while ?
Irue
St represents the set of statements to be
The while iteration statement tests
repeated. statement
the condition before entering into the loop.
Thus, if the condition is false even before
entering into the loop, the while-loop will statement
-
Draw a Flowchartto find Area and Perimeter of Rectangle, along with algorithm in simple English.
EXAMPLE3
L:
Length of Rectangle, B: Breadth of Rectangle
AREA: Area of Rectangie, PERIMETER : Perimeter of Rectangle (Start
SOLUTION
Inputvalue of L, B
Algorithm
Step 1. Start AREA=LxB
Step 2. & Breadth say L, B
Step Input Side-Length
PERIMETER =2 x(L +B)
Step B. AREA -LxB
Step 4. PERIMETER-2x(L+B) Print AREA, PERIMETER
Step
Step 5. Print AREA, PERIMETER
English.
SOLUTION Read a, b
Algorithmn
Step1. Start Yes
a >b
No
Step 4 Stop
Stop
EXAMPLE 6 Draw a
flow chart to print even numbers from 2 to 10* using a loop approach, along w
algorithm in simple English.
SOLUTION Start
Algorithm
i 2
Step 1. i-2
Step 2. While i< 10
Repat steps 3 through 4 False
10
Step 3. Print i .
True
Step:4. i-i+2
Step 5. Stop Stop Printi
5: INTRODUCIION TO PROBLEM SOLVING 119
Chapter
EXAMPLE
Draw a flow chart to calculate 2*,
along with algorithm in simple English.
sOLUTION
Start
Algorithm
Print Product
Stop
EXAMPLE8 Draw a flow chart to calculate 2 using a loop approach, along with algorithm in simple English.
SOLUTION
Start
Algorithm
Step 1. Input Base (2), Power (4)
Input base (2),
Power (4)
Step 2. Product -Base
Step 3. Counter-1 Product= Base
Step 4. While (Counter < Power) Counter =1
Repeat steps 4 through 6
Product= Counter + 1
Stop
120 COMPUTER SCIENCE WITH PYTHON
5.3.2 Pseudocode
Pseudocode is an informal language that helps programmers describe steps of a progan
solution without using any programming language syntax. Pseudocode is a "text-based"det
(algorithmic) design tool. A pseudocode creates an outline or a rough dratt of a programtletail
that
gives the idea of how the algorithm works and how the control flows from one step to another
ther.
For example, consider the following pseudocode
NOTE
If student 's marks is greater than or equal to 56
Pseudocode is an informal way
display "passed" of describing the steps of a
else program's solution without
using any strict
programming
display "failed language syntax or underlying
The above pseudocode gives you an idea how a program technology considerations.
determines whether a student has passed or failed comparing
the marks of the student.
Consider the same algorithm that we talked in example 5 (determine if the first mumber is
greater than the second number or not). The pseudocode of this algorithm can be like :
disadvantages too.
Pseudo-code Advatages
I t uses a language similar to everyday English, thus is easy to.understand.
IF word = 'x'
EXAMPLE9 Write pseudocode that converts from
Ealrenheit to Celsius or from Celsius to Fahrenheit, PRINT number of words entered
INPUT ask what number? EXAMPLE 11 Write pseudocode that asks how
y
IF 1 is pressed many numbers (say n), and then print all those numbers
# do f t c conversion after n numbers have been entered.
C=5/9*(F - 32) SOLUTION Pseudocode:
PRINT Output C
INPUT value of n #howmany numbers
ELSE IF 2 is pressed
# do c to f conversion
Initialise numbercount
Initialise listnum as an empty list
F 9/5 * (C+ 32)
WHILE the numbercount <= n
PRINT output F
ask for a number
ELSE add one to number count
PRINT "Please enter either 1 or 2"
add number to listnum
# now the numbers have been entered, loop is over
EXAMPLE 10 Write pseudocode that lets the user:
# take listnum' s numbers in item one by one
type words and when they press '*', it prints how many
FOR item in listnum
words the user inputted then quits program.
PRINT item
SOLUTION Pseudocode
# item now takes next number in listnum
WHILE true
INPUT "Enter a Word"
PRINT wOrd
Trace Tables
Dry running an algorithm is carried out using trace tables where the impact of each line of the
code is seen on the values of, variables of the algorithm. As per the line of the code, the
processing that takes place is applied on the variables' values.
For example, wé want to calculate the double of the numbers in sequence 1, 2, 3 and print the
value as 1 added to the double value
To see
Dry Run 1. FOR number <- 1 TO 3
action
V a l - number * 2
3. PRINTVal +1
The trace table for the above code will record the code movement and its impact on
Scan
QR Code
the variables, line by line:
6
3
7
So the given code's trace table will be as shown above, when the code is The
above given trace table has documented the dry-run.
impact of each line of the code separately.
tar 5 : INTRODUCTION TO PROBLEM SOLVING 123
However, you can skip this style and simply show the impact of code on variables too, eg, as
shown below:
Print
Line numbers Number Valnumber *2 Val +1
1-3 1 2 3
1-3 4 5
1-3
NOTE
You can choose to skip line numbers too, if
Trace tables enable the variable values
in an algorithm
you want as we have done in the example
to be recorded as the algorithm is dry
run.
below.
1. Name some useful tools for program should you choose for coding?
another,
decide which algorithm to choose
over
development. In order to
2. What is the difference between an factor.
efficiency will be the deciding
their
algorithmand pseudocode? efficiency of an algorithm are:
3. Which of the following is graphica? Major factors that govern the
to find the solution and
(a) algorithm (b) flowchart the time it takes
which are consumed in the process.
c)pseudocode (d) dry run the resources
Which of the following usefil för buying a car, how do you choose a car
For instance while
tracing a pseudo code ?
avaílable choice? Yup, you are absolutely right; you
from and the fuel.consumption.
(a) algorithm (b) flowchart both the speed
might consider to you, will win.
()pseudocode (d) dry run the most
The factor that matters
. What is the use of trace table ?
124 COMPUTER SCIENCE WITH PYTHON - XI
When you have hardware platform fixed with a specific RAM size, then space efficiene
becomes the deciding factor and the algorithms that takes up less space is chosen.
With this we have come to the end of this chapter. Let us quickly revise what we have leamt so
far in this chapteer.
LET US REVISE
is decomposition ?
5. What
(a) Breaking code down once it has been run
(6) Breaking a problem down into smaller, more manageable sections
()Breaking a problem into subroutines (d) Breaking big data into small data
(a) Using variables and data (b) Using inputs and outputs
(c) Using pseudo-code and flowcharts (d) Using functions and procedures
7. What is true for
the term Decomposition ?
(a) It uses computers to solve problems.
False False
S2
(1) (2)
how many times the loop is iterated?
9. Consider the following pseudocode and determine
while i #5
i:=i+1
1 $1
2 while C
3 S2
4 S3
(a) S1 S3 (b) S1 $2; $3
S3
(c) S1;$2 ; S2; $3 (d) S1; $2; $2; $2;
. Which of the following activities is algorithmic in nature
(b) Describe a bicycle.
(a) Assemble a bicycle.
how bicycle works.
(c) Label the parts of a bicycle. (d) Explain a
13. The process of checking the correctness of an algorithm by checking the variables' values after
steps, without actually running the program is every
(a) No execution (b) Dry run (c) Dry output (d) Dry test
14. The purpose of a trace table is that
(a) it used to record the results from each step in an algorithm;
(b) it used to record the image from flowchart
(c) it used to store variable names
(d) it used to store the output
15. Look at the Algorithm below. In the corresponding Trace Table, what value should 'E' be ?
5 3
(a) 3
3 2
(b) 8
4 13
(c) 3
5 13
(d) 18
3 E
4 16
5 F
16. Look at the Algorithm below. In the corresponding Trace Table, what value should 'F be ?
2 PRINT number
Line number OUTPUT
3
FOR i from 1 to 3
4 3
number =
number +5
PRINT number
8
8
3
2
4 13
(a) 3
13
(6)8
(c) 13
18
(d) 18
5
17. What are the common factors for comparing the two
algorithms doing the same work ?
(a) Space b) Time
(c) programming language (d) both (a) and (b) (e) (a), (b), and (c).
Chopter
ofer 5 : INTRODUCTICN TO PROBLEM SOLVING 127
True/False Questions
1. An algorithm is the step by step solution of a problem.
2. While solving a problem, you start coding from the first step.
3. Decomposition is an additional task, which may be avoided.
4. Decomposition is necessary as larger problems are harder to code.
5. A flowchart is a graphical tool to represent an algorithm.
6. A rectangle symbol in a flowchart represent process.
7. A diamond symbol in a flowchart represents a loop.
8. A diamond symbol in a flowchart represents a condition.
9. Testing and debugging is an optional step in problem solving
10. A thorough analyzed problem yields a better solution.
1. Dry run and trace table are the algorithm verification tools.
NOTE: Answers for OTQs are given at the end of the book.
Solved Problems
. Mention the steps you would follow while writing a program.
Solution. The steps to creating a working program are
language.
4. What do you understand by analysing an algorithm ?
Solution. Problem analysis is an important phase as its success leads to the final solution. In problem
analysis, mainly following things are carried out:
identifying processing components.
identifying the relationships among processing components.
5. What is testing and debugging?
Solution. Testing is the process of finding errors in a program and debugging is the process of
correcting errors found during the testing process. Thus, the testing and debugging involves :
finding errors in the program. rectifying the errors, which have been found.
6. How do you implement Decomposition while problem solving?
Solution. Decomposition is implemented by dividing the main algorithm into functions. Then one
constructs each function independently of the main algorithm and other functions. Finally, the main
algorithm is constructed using the functions.
When we use the functions, it is enough to know the specification of the function without knowing
how the function is implemented.
START
7. Draw a flowchart to find the largest of three
numbers A, B, and C.
READ A, B, C
Solution.
END
5 INTRODUCTION TO PROBLEM SOLVING
Chapter
129
raflowchart to fina the sum of first 50 natural 10.
Drawa flow chart to count and print from 1 to 10.
numbers
Solution.
Solution.
START Start
N0
Count Low
N=N+1
S
No
Count s High
SUM SUM+1
Yes
Print count
IO
ISN 50? Stop
3: Counter = 1
DF DF M
4: While (Counter £ N)
Repeat steps 4 through 6
5: Factor = F a c t o r * Counter
END
130 COMPUTER SCIENCE WITH
PYTHON
13. Draw a flow chart to calculate the factorial of a: 15. Write pseudocode to print Even numbers
umbers between
number (N). to 50.
Solution. Solution.
Start
12 I =1
Start
3: While I <= 50
DisplayyI
Factorial = 1 #END of IF
5 I I+1
7 Stop
Counter 1
16. Write pseudocode to get a number and check
ifit is
prime.
Solution.
Is
No INPUT number
CountersN
prime<-TRUE
Yes FOR i - 2 TO number
IF number is divisible byi then
Factorial = Factorial * Counter
Print Factorial prime FALSE
IF prime =TRUE:
Counter =Counter +1| Stop PRINT "prime"
ELSE
PRINT "not prime"
Output
19 Dry run the algorithm given below ohich contains a for loop inside another for loop. Show the trace table.
num-0
total-0
FOR i - 1 TO 3
FOR j - 1 TO 3
num-j *i
total-total + num
# END of inner FOR
# END of outer FOR
PRINT total
2 8
12
18
3 21
27
3 36
36
1. Write pseudocode that reads frvo numbers and divides one by another and displays the quotient.
Ans.
INPUT num1, num2
quotient num1/num2
PRINT quotient
2. Two
coin five times. 1he first person to win three
ends decide who gets the last slice of a cake by flipping a
ps oins the cake. An input of 1 means player 1 wins a flip, and a 2 means player 2 wins afip. Design an
algorithm to ermine who takes the cake ?
132 COMPUTER SCIENCE WITH PYTHON
- X
total1
PRINT 'Percentage = , perc
3. Write the pseudocode to print all multiples of 5 8. Write an algorithm to find the greatest among tim
two
between 10 and 25 (including both 10 and 25). different numbers entered by the user.
Ans. FOR i in sequence 10. .25 Ans.
IF i modulus 5 = 0 THEN
INPUT num1, num2
PRINT i IF num1 > num2
#End of IF PRINT num1
#End of FOR ELSE IF num2> num1
4. Give an example of a loop that is to be executed a PRINT num2
certain number of times. ELSE
Ans. The FOR loop, can be executed a certain PRINT 'both are equal'
number of times e.g-, 9. Write an algorithm that performs the following
For i in sequence 1..5 Ask a user to enter a number. If the number is
PRINT i between 5 and 15, write the word GREEN. If the
number is between 15 and 25, write the word
5. Suppose you collecting money for something.
are
BLUE. 1f the number is between 25 and 35, write
You need 200 in all. you ask you parents, uncles
the word ORANGE. If it is any other nmumber,
and aunts as well as grandparents. Different people
write that ALL COLOURS ARE BEAUTIFUL
may give either T10, F10 or even T50. You will collect
till the total becomes 200. Write the algorithm. Ans.
Ans. Total = 0
INPUT num
IF num >= 5 and <= 15 THEN
WHTLE Total < 200
PRINT 'GREEN'
INPUT money
ELSE IF num >= 15 and <= 25 THEN
Total Total +Money PRINT 'BLUE'
#End of while
ELSE
6. Write the pseudocode to print thebill depending upon PRINT 'ALL COLOURS ARE BEAUTIFUL
the price and quantity
of am
item. Also print Bill GST,
which is the bill after adding 5% of tax in the total bill.
10. Write algorithm that accepts four numbes
an
11put and find the largest and smallest of then
Ans.
Ans.
INPUT itemname, price, qty
INPUT n1, n2, n3, n4
billamount = price * qty
IF n1> n2 and n1> n3 and n1> n4 THEN
gstamount = billamount * 0.e5
PRINT n1 'is greatest' THEN
PRINT itemname, price, billamount ELSE IF n2 > n2>
n1 and n2> n3 and n 2 >
n4
*
PRINT 'Total amount = ', billamount + gstamount ELSE IF n3 > n1 and n3> n2 and n3> n*
7. PRINT n3 'is greatest'
Write pseudocode that will perform the following: ELSE IF n4> n1 and n4> n2 and n4
THEN
Ans.
INPUT units Flow of Control
250 THEN
IFunits
*
bill (units-250) 75 + 150 *
10 + 100 *
14. Following is an algorithm for going to school or
ELSE IF units > 100 THEN
bill = (units-100) * 10 + 100 * 5 college.Can you suggest improvements in this to
include other options ? Reach_School_Algorithm
ELSE
bill = units * 5
(a) Wake up (6) Get ready
(c)Take lunch box (d) Take bus
PRINT units, bill
() Get off the bus
() Reach school or college
12. What are conditionals? When they are required in;
a program
Ans. It can be modified to incorporate
situations where a different course of action is
Ans. Conditionals are the statements that test a
required, e.g., if bus is missed.
condition.
Wake up
Conditionals are required in a program where
Get Ready
the control has to take different flow-of-action Take Lunch Box
depending upon a condition's result. IF taken bus THEN
13. Match the Ride the bus
pairs
Flowchart Symbols Functions Get off the bus
ELSE #if bus missed
Flow of Control Take other means of transport
Get down at schoo1
Reach School or College.
Process Step
15. Write a pseudocode to calculate thefactorial ofa munber
(Hint. Factorial of5, written as 5! 5x4x3x2 x 1).
Start/Stop of the Process
Ans. INPUT num
F 1
WHILE num> 1
Data F F* num
num = num 11
#end of while
Decision Making PRINT F
134 COMPUTER SCIENCE WITH PYTHO
PYTHON -
16. Draw a flowchart to check whether a given number 4. Else IF Number < 99
is an Armstrong number. An Armstrong number 5. "Double Digit"
of three digits is an integer such that the sum of the 6. ELSE
cubes of its digits is equal to the number itself. For 7. "Big"
example, 371 is an Armstrong number since:
3**3+17**3+1**3 371. Lines
Number OUTPUT
Ans. Executed
NOTE
1, 2, 3
Start mod gives remainder Single Digit
9 1, 2, 4, 5
div gives quotient Double Digit
INPUT num a**b means a" 47 1, 2, 4, 5 Double Digit
99 1, 2, 4, 6, 7 Big
100 1, 2, 4, 6,
d1 num mod 10
q1 = num div 10
7
Big V
d2 q1 mod 10 200 1, 2, 4, 6, 7
q2 q1 div 10
Big
d3 = q2 mod 10
The error in given
algorithm is that it should
also test for equality i.e., as
n1 =
d3 **
3+ d2 **
3 + d1 **
3
INPUT Number
IF Number
Is
<= 9
num = n1
No "Single Digit"
ELSE IF Number
<= 99
Yes 'Double Digit"
PRINT 'not an ELSE
Armstrong number
PRINT "Big"
'Armstrong number
18. For calculations, we want an algorithmt
some that
accepts only positive integers upto 100.
Stop Accept 1to100_Algo
17. Following is an algorithm to classify numbers INPUT Number
as IF (0 =
Single Digit", "Double Digit" or "Big". Number) AND (Number <= 100)
ACCEPT
Classify_Numbers_Algo Else
INPUT Number REJECT
If Number < 9
(a) On what values will this algorithm fail ?
"Single Digit" (b) Can you
Else If Number < 99 improve the algorithm?
"Double Digit" Ans.
Else ()The given algorithm will fail at inpa
"Big" number as zero
(0).
Verify for (5, 9, 47, 99, 100, 200) and correct the (b) Corrected algorithm:
algorithm if required. INPUT Number
Ans. IF (0 < Number) AND (Number <= 100)
1. INPUT Number ACCEPT
2. IF Number < 9 ELSE
3. "Single Digit" REJECT
INTRODUCTION TO PROBLEM SOLVING
Chopter 5 :INTR
135
GLOSSARY
Pseudocode
Logic written in English which looks like a programming language but not actually a programming language.
Testing a program with pen and paper, by tracing the impact of each statement on varidbles.
Dry Run
Assignmenfs
pe A:
Short Answer Questions/Conceptual Questions
1. What are the phases of program solving cycle?
while analysing a problem ?
2. What do you do
3. What is done during coding phase ?
4. What is testing and debugging ?
5. Distinguish between a condition and a statement.
6. Draw a flowchart for conditional statement.
7. Both conditional statement and iterative statement have a condition and a statement. How do they differ?
8. What is decomposition ?
9. Name some tools used for problem solution development.
10. What is the difference between an algorithm and a program ?
[Hint: Start
else
No
Print "PASS" Yes grade 50 «
# end of if
START
/Read X, Y, Z
Yes No
Is X>Y?
Yes IsX>2?
No No ls Y>Z? Yes
Print 'The largest number is', X Print The largest number is', Y
(STOP
(b)
Start
c 0 , s =0
Yes
Stop
Input num
S s+ num
CC+11
and
7 Write algorithm to display the sum of two numbers entered by user, using both pseudoco
an
flowchart.
INTRODUCTION TO PROBLEM SOLVING
Chapter5 : 137
Dea7a flowchart, write an agorithm and pseudo code for the following questions 8-24
oTo find the area and perimeter of a rectangle.
To
calculate the area and the circumference of a circle.
Draw a flow chart for the same and dry run the given pseudocode if it is working fine.
26. Given the following pseudo code:
Use variables: choice, of the type character
ans, number1, number2, of type integer
d1splay "choose one of the following"
display "m for multiply"
display "a for add"
display "s for subtract"
accept choice
alsplay "input two numbers you want to use
accept number1, number2
f
choice m then
=
ans =
number1 *
numberz
T
choice =a then ans number1 +numberz
lt choice =
s then ans numberl number2
W
D
display ans
a flow chart for the same and dry run the given pseudocode if it is working fine.
COMPUTER SCIENCE WITH
138 THON
code
27. Given the following pseudo
Use variables: mark of type integer
"distinction"
If mark = 80, display
If mark = 60 and mark < 80, display "merit"
If mark = 40 and mark < 60, display "pass"
If mark < 40 display, "fail"
Draw a flow chart for the same and dry run the given pseudocode if it is working fine.
Draw a flow chart for the same and dry run the given pseudocode if it is working fine.
Draw a flow chart for the same and dry run the given pseudocode if it is working fine.
CHAPTER 5 INTRODUCTION To PROBLEM SOLVING
Multiple Choice Questions
1. (a) 2. (b) 3. (b) 4. (), (d) 5. (b) 6. (c)
7. (c) 8. (a) 9. (b) 10. (a) 11. (a) 12. (d)
13. (b) 14. (a) 15. (a) 16. (d) 17. (b)
True/False Questions
1. T 2. F 3. F 4. T 5. T 6. T
7. F 8. T 9. F 10. T 11. T 12. F