0% found this document useful (0 votes)
4 views

Introduction to problem solving

This document introduces problem-solving concepts, emphasizing the importance of using computers to automate tasks across various disciplines. It outlines the steps involved in problem-solving, including understanding the problem, formulating a model, developing an algorithm, writing a program, testing it, and evaluating the solution. Additionally, it discusses the role of algorithms in providing structured approaches to solving problems and highlights the significance of problem-solving skills in personal and professional contexts.

Uploaded by

A. Light
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Introduction to problem solving

This document introduces problem-solving concepts, emphasizing the importance of using computers to automate tasks across various disciplines. It outlines the steps involved in problem-solving, including understanding the problem, formulating a model, developing an algorithm, writing a program, testing it, and evaluating the solution. Additionally, it discusses the role of algorithms in providing structured approaches to solving problems and highlights the significance of problem-solving skills in personal and professional contexts.

Uploaded by

A. Light
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Introduction to Problem Solving

Often, the term computerization is used to describe the process of developing


computer software that automates any routine human task efficiently. Computers
are tools invented by humans to help them solve various day-to-day problems more
efficiently and with ease. Thus, this course intends to familiarize students with the
necessary skill to employ in using computers to solve problems.
Nowadays, the use of computers to solve problems is not restricted only to
computer scientists and Management Information Technology specialists (MIT),
all other disciplines are keying into using computers as a tool for solving problems
in their domains. For instance, engineers build simulators using computer programs
to serve as a prototype of their full-scale projects, scientists are building programs
to monitor their experimental procedure, social scientists use computers to solve
research related problems to improve understanding of social aspects of human
beings and so on. Thus, inclusion of problem-solving concepts in the
undergraduate curriculum is very important, as it prepares the minds of the
undergraduate to be able to cope with the current technology driven real work
tasks.
It is pertinent to mention that computers on their own cannot solve any problem,
they require precise step-by-step instructions from the humans on how to solve a
given problem. This makes it very important for anyone who wants to develop a
computerized solution to a given problem to understand how to solve the problem
and how to convert the solution arrived at into instruction that a computer can
follow to arrive at an accurate result. Thus, the success of a computer in solving a
problem depends on how correctly and precisely we define the problem, design a
solution (algorithm) and implement the designed solution (program) using a
programming language. Therefore, solving a problem requires identifying a
problem, developing an algorithm for the identified problem and finally
implementing the algorithm to develop a computer program.
Problem-solving (PS) skills are needed in all areas of life, including classroom
problem solving activities. The capacity to decisively analyze a problem, and set
up an effective Solution is one of the most valuable skills one can acquire in life, in
school, work or in a social circle. Training in this regard promotes cognitive, social
development, and can prepare students with the skills needed to address and solve
problems all the way through the rest of their lives. In reality, whatever activity
human beings or machines do to achieve a specified objective comes under
problem solving.

Problem - Meaning

A problem is a task. Generally, A problem is a kind of barrier to achieve something


and problem solving is a process to get that barrier removed by performing some
sequence of activities. Thus, PS is an act of defining a problem; determining the
cause of the problem; identifying, prioritizing and selecting alternatives for a
solution; and implementing the Solution. Learning in a problem-solving method is
by working on problems. Students learn new knowledge by solving problems. This
is done through observation, understanding, analyzing, interpreting to find
solutions, and performing applications that would give insight to a holistic
understanding of the concepts. Overall, PS is a process - ability to work from
known and discover unknown. The ability to solve problems is a basic life skill and
is essential to our day-to-day lives, at home, at school, and at work. We solve
problems every day without really thinking about how we solve them. For
example: it’s raining and you need to go to the store. What do you do? There are
lots of possible solutions. Take your umbrella and walk. If you don't want to get
wet, you can drive, or take the bus. You might decide to call a friend for a ride, or
you might decide to go to the store another day. There is no right way to solve this
problem and different people will solve it differently.
Problem solving is the process of identifying a problem, developing possible
solution paths, and taking the appropriate course of action.

Problem Solving is the sequential process of analyzing information related to a


given situation and generating appropriate response options.

Problem solving is a critical skill in computer science and programming. It refers


to the process of finding solutions to problems or challenges by applying logic and
critical thinking. Problems are solved using a computer by obtaining some kind of
user input (e.g., keyboard/mouse information or game control movements), then
processing the input and producing some kind of output (e.g., images, test, sound).
Sometimes the incoming and outgoing data may be in the form of hard drives or
network devices.

Why is problem solving important? Good problem solving skills empower you not
only in your personal life but are critical in your professional life. In the current
fast-changing global economy, employers often identify everyday problem solving
as crucial to the success of their organizations. For employees, problem solving can
be used to develop practical and creative solutions, and to show independence and
initiative to employers.

There are 6 steps that you should follow in order to solve a problem:
1. Understand the Problem
2. Formulate a Model
3. Develop an Algorithm
4. Write the Program
5. Test the Program
6. Evaluate the Solution
Examples of PS:
Example 1: A simple example on input/process/output. Calculate the average
grade for all students in a class.
Input: get all the grades … perhaps by typing them in via the keyboard or by
reading them from a USB flash drive or hard disk.
Process: add them all up and compute the average grade.
Output: output the answer to either the monitor, to the printer, to the USB flash
drive or hard disk … or a combination of any of these devices. To solve the
problem, we need to understand the problem. Thus, these questions???????
● What input data/information is available?
● What does it represent?
● What format is it in?
● Is anything missing?
● Do I have everything that I need?
● What output information am I trying to produce?
● What do I want the result to look like … text, a picture, a graph … ?
● What am I going to have to compute?

In the example,
● The input is a bunch of grades
● We need to understand the format of the grades
● Each grade might be a number from 0 to 100
● It may be a letter grade from A to F
● If it is a number, the grade might be a whole integer like 73 or it may be a
real number like 73.42
● Need to consider missing grades, if we do not have the grade for every
student (e.g.,some were away during the test) ????
● Understand what the output should be (output a whole or real number or a
letter grade??????)
● Display results using charts

The need to understand the processing part of the problem. Break the problem into
smaller problems that require some kind of simple mathematical computations in
order to process the data since we are going to compute the average. So, what is the
model (or formula) for computing the average of a bunch of numbers? If there is
no such “formula”, then, there is a need to develop one. Sometimes, we can look
up certain formulas in a book or online if we get stuck. To come up with a model,
we need to fully understand the information available to us.
Assuming that the input data is a bunch of integers or real numbers x1,x2,…,xn
representing a grade percentage, we can use the following computational model:
Average1 = (x1 + x2 + x3 + … + xn) / n

Assuming the input number is from 0 to 100.


Conversely, the approach will not work if the input data is a set of letter grades like
B, C, A, F, D, etc.. because we cannot perform addition and division on the letters.
Then, thinking is required. Assuming, we may decide to assign an integer number
to the incoming letters as follows:
A= 12 B= 9 C= 6 D= 3 F= 0
If we assume that these newly assigned grade numbers are y1,y2,…,yn, then we
can use the following computational model:
Average2 = (y1 + y2 + y3 + … + yn) / n

where the result will be a number from 0 to 12. The next is formulating an
algorithm.

Example 2: On school resumption day, a student is ready to go to school but yet


he/she has not picked up the required books and copies which are required as per
timetable. As a result, picking up books and copies according to timetable is a kind
of problem solving.

Example 3: Some students in a class plan to host an event and decide to share the
expenses among them. So, making up plans including budgets, noting all activities,
risks, alternatives, etc. is also a kind of problem solving.
The problems that we want to solve can come from any real-world problem or
perhaps even from the abstract world. We need to have a standard systematic
approach to solving problems. The three basic purposes include:
1.Seeking information
2.Generating new knowledge
3.Making decisions

Steps in problem solving


Considering a scenario where while driving, the vehicle starts making a strange
sound. One may not know how to solve the problem right away. The question that
will come to one’s mind is: where is the noise coming from? What is the cause of
the strangeness? Can I fix it or I need a specialist? In the case where a mechanic is
required, the first thing he will do is to identify where the strange sound is coming
from, analyze the cause of the strange sound, and come up with the solution before
embarking on the repair. Therefore, from the above scenario, it is explicit that
finding the solution to a problem might consist of multiple steps.
When problems are straightforward and easy, we can easily find the solution. But a
complex problem requires a methodical approach to find the right solution. In other
words, we have to apply problem solving techniques. Problem solving begins with
the precise identification of the problem and ends with a complete working
solution in terms of a program or software. Key steps required for solving a
problem using a computer are as follows:
1. Understand the Problem
It is one thing to know there is a problem and it is another thing to actually know
what the problem is. The process that leads to a conclusion that there is a problem
is what is called problem identification while the process of finding the cause and
solution of the problem is what is called problem analysis. It is important to clearly
identify and understand a problem before embarking on finding a solution for it. If
a problem to be solved is not well understood, it may lead to development of a
solution that may not be effective, efficient or even add to the existing problem.
After identification of the problem, it must be documented accurately because
humans are likely to forget with increasing pressure and distractions.
2. Formulate a Model
Now we need to understand the processing part of the problem. Many problems
break down into smaller problems that require some kind of simple mathematical
computations in order to process the data. In example 1 above, we got to compute
the average of the incoming grades. Using a model (or formula) for computing the
average of a bunch of numbers. In order to come up with a model, we need to fully
understand the information available to us.
3. Develop an Algorithm
It is essential to design a solution before writing any program code for a given
problem. In construction, a plan is designed first to serve as a guide during actual
construction, so it is in computing with regard to problem solving: where a design
is represented in the form of algorithms. We can imagine an algorithm like a very
well-written recipe for a dish, with clearly defined steps that if followed, one will
end up preparing the dish.
Algorithm design is a process, it starts with a tentative solution plan which is
continuously refined until the algorithm is able to capture all the aspects of the
desired solution. For a given problem, more than one algorithm is possible and
selecting the most suitable algorithm is the key to an efficient solution.
4. Write the Program
Now that we have a precise set of steps for solving the problem, most of the hard
work has been done. We now have to transform the algorithm from step 3 into a set
of instructions that can be understood by the computer. Writing a program is often
called "writing code" or “implementing an algorithm”. So the code (or source
code) is actually the program itself.
5. Test the Program
Once you have a program written that compiles, you need to make sure that it
solves the problem that it was intended to solve and that the solutions are correct.
When you run your program, if all is well, you should see the correct output. It is
possible however, that your program works correctly for some set of data input but
not for all. If the output of your program is incorrect, it is possible that you did not
convert your algorithm properly into a proper program. It is also possible that you
did not produce a proper algorithm back in step 3 that handles all situations that
could arise. Maybe you performed some instructions out of sequence. Whatever
happens, such problems with your program are known as bugs. You should fix as
many bugs in your program as you can find. To find bugs effectively, you should
test your program with many test cases (called a test suite). It is also a good idea to
have others test your program because they may think up situations or input data
that you may never have thought of. The process of finding and fixing errors in
your code is called debugging and it is often a very time-consuming “chore” when
it comes to being a programmer. If you take your time to carefully follow problem
solving steps 1 through 3, this should greatly reduce the amount of bugs in your
programs and it should make debugging much easier.
6. Evaluate the Solution
Once your program produces a result that seems correct, you need to re-consider
the original problem and make sure that the answer is formatted into a proper
solution to the problem. It is often the case that you realize that your program
solution does not solve the problem the way that you wanted it to. You may realize
that more steps are involved.

Advantages of Problem-Solving Method


● Development of Long-Term Knowledge Retention– the ability to retain
and recall information as a result of open discussion between peers
reinforces understanding of subject matter.
● Use of Diverse Instruction Types - Grouping “students” together allows
them to work together and enjoy team-based learning. Content such as
video, news articles and more could also be provided.
● Continuous Engagement – It is not hard to see the potential for
engagement, as students collaborate to solve real-world problems that
directly affect or heavily interest them.
● Development of Transferable Skills – It allows learning to become more
profound and durable, helping students apply skills they develop to other
real-world scenarios.
● Improvement of Teamwork and Interpersonal Skills – promotes
interaction and communication, leading to building skills related to
teamwork and collaboration.
Introduction to Algorithms

Introduction
One common problem in science has been the overload that occurs when the
demand on working memory exceeds its capacity. Solution to this overload is to
help students build strategies that decrease a task's demand on working memory.
These strategies have been described as the tricks for simplifying problems.
Problem solvers go through certain steps while working on a problem. These may
be more or less as follows;
● Begin by reading the problem
● Perhaps more than once
● Then write down hopefully, the key information
● Reread the question or a part of the question
● Draw a picture to help represent the question
● Then try something
● Try something else
● Look at where it leads
These strategies are algorithms that automate individual steps in solving problems.
Thus,
gradually exploring or playing with the question individuals get closer and closer
to the answer.

Algorithm
Algorithm is the set of step-by-step measures or rules followed to complete a given
task or solve a particular problem. It is “a process that performs some sequence of
operations in order to solve a given problem”. The set of rules must be
unambiguous and have a clear stopping point. Note that there might be other ways
to solve a problem; as a result, there may be more than one algorithm for a
problem. Algorithms are used in calculation, data processing, and many other
fields. They are essential because algorithms provide the organized procedures that
computers require.

Example of Algorithm
Problem to solve: Write an algorithm to read two numbers and find their sum.
Inputs to the algorithm (accept two inputs):
● First num1
● Second num2
Expected output:
● Sum of the two numbers
Algorithm:
Step1: Start
Step2: input the first num1.
Step3: input the second num2.
Step4: Sum = num1+num2
Step5: Print Sum
Step6: End

Role of Algorithm in problem solving


Vital role played by algorithms in problem solving are as follows:
1. It guides programmers during coding.
2. It is used for testing the correctness of the logic in the proposed solution.
3. It allows designers to test the solution with real data before implementation
thereby reducing risk of failed projects.
4. It can also serve as documentation in case of porting or upgrade.
5. It clearly reveals the flow of control during execution of the program.

Characteristics of an Algorithm
● Precision: the steps are precisely stated or defined accurately.
● Uniqueness: results of each step are uniquely defined and only depend on
the input and the result of the preceding steps.
● Finiteness: An algorithm always stops after a finite number of steps.
● Input: An algorithm must have some form of input.
● Output: An algorithm must produces some output
● Unambiguous: Each step in an algorithm should have only one
interpretation.

Types of Algorithm
Algorithms are classified according to what they are being used to achieve. The
basic types of computer science algorithms include:
● Divide and conquer algorithms – divide the problem into smaller
subproblems of the same type; solve those smaller problems, and combine
those solutions to solve the original problem.
● Brute force algorithms – try all possible solutions until a satisfactory
solution is found.
● Randomized algorithms– use a random number at least once during the
computation to find a solution to the problem.
● Greedy algorithms – find an optimal solution at the local level with the
intent of finding an optimal solution for the whole problem.
● Recursive algorithms– solve the lowest and simplest version of a problem
then, solve increasingly larger versions of the problem until the solution to
the original problem is found.
● Backtracking algorithms – divide the problem into subproblems, each which
can be attempted to be solved; however, if the desired solution is not
reached, move backwards in the problem until a path is found that moves it
forward.
● Dynamic programming algorithms – break a complex problem into a
collection of simpler sub problems, and then solve each of those sub
problems only once, storing their solution for future use instead of
re-computing their solutions.

Importance of Algorithm
Algorithmic thinking is vital in many different fields. Some of the benefits are:
● Allows students to breakdown problems and conceptualize solution in
distinct steps
● Being able to understand and implement an algorithm necessitates students
to exercise planned assessment and reasoning abilities.
● By using an algorithm, decision making becomes a more rational process.
● Makes PS process more efficient and consistent

Implementing or Expressing Algorithms


Algorithms can be expressed in many notations including:
● Natural languages: tend to be verbose and ambiguous and rarely used for
complex or technical algorithms.
● Programming language: intended for expressing algorithms in the form
that can be executed by a computer.
● Flow charts and Pseudo codes: both are structured ways to express
algorithms that avoid many ambiguities common in natural language
statements, while remaining independent of a particular implementation
language. Sometimes it is helpful in the description of an algorithm to
supplement small flowcharts with natural language and/or arithmetic
expressions written inside block diagrams to summarize what the flowcharts
are accomplishing.
Flowchart

Introduction
A flowchart is a visual representation of an algorithm, workflow or process,
showing the steps as boxes of various kinds, and their order by connecting them
with arrows. This diagrammatic representation illustrates a solution model to a
given problem. Flowcharts are used in analyzing, designing, documenting or
managing a process or program in various fields. Like other types of diagrams,
they help visualize what is going on and thereby help understand a process, and
perhaps also find flaws, bottlenecks, and other less-obvious features within it. Each
shape represents a step of the solution process and the arrow represents the order or
link among the steps. There are many different types of flowcharts, and each type
has its own repertoire of boxes and notational conventions. Common alternative
names include: flowchart, process flowchart, functional flowchart, process map,
process chart, functional process chart, business process model, process model,
process flow diagram, workflow diagram, business flow diagram.
A well-made flowchart can be used to break big ideas into small, bite-sized pieces
that are expressed visually, so knowing how to make one is sort of like having a
universal language. Being able to flowchart makes it possible to communicate with
any stakeholder or audience, because visuals are typically easier to understand than
words. For this reason, flowcharts are a valuable type of business diagram but can
also be used for more technical fields like manufacturing or software engineering.

Symbols Used in Creating a Flowchart


Whether you're trying to read a flowchart or creating a flowchart, knowing the
most common flowchart symbols and conventions is going to make it a lot easier.
Table 2-3-1 presents a list of common flowchart symbols you need to know, plus a
rundown on some more intermediate process symbols if you're looking for extra
credit.

Flowchart Symbol Symbol Name Description


Terminal/Terminator It indicates where the flow
starts and ends.

Process
It represents a process,
action, or a single step.

Decision A decision or branching


point, usually a yes/no or
true/ false question is asked,
and based on the answer, the
path gets split into two
branches.

Data or Input/Output This parallelogram shape is


used to input or output data.
Flow Arrow It represents the direction of
the process flow.

Table 1.1 Basic Flowchart Symbols

As pointed out earlier, flowcharts illustrate where data are being input and output,
where information is being stored, what decisions need to be made, and which
people need to be involved. In addition to the basic flowchart conventions, rules,
and symbols, there are intermediate flowchart symbols that help describe a process
with even more detail.

Differences between Algorithm and Flowchart

Algorithm Flowchart
1. A method of representing the 1. Flowchart is a diagrammatic
step-by-step logical procedure for solving representation of an algorithm. It is
a problem constructed using different types of boxes
and symbols.

2. It contains step-by-step English 2. The flowchart employs a series of


descriptions, each step representing a blocks and arrows, each of which
particular operation leading to solution of represents a particular step in an algorithm
problem

3. These are particularly useful for small 3. These are useful for detailed
problems representations of complicated programs
4. For complex programs, algorithms 4. For complex programs, Flowcharts
prove to be inadequate prove to be adequate

Advantages of Flowcharts
1. It is the most efficient way of communicating the logic of the system.
2. It acts as a guide for a blueprint during the program design.
3. It also helps in the debugging process.
4. Using flowcharts we can easily analyze the programs.
5. flowcharts are good for documentation.

Sample Flowcharts
1. Draw a flowchart to find the square of a number
Algorithm
Step 1: Start
Step 2: Input number num.
Step 3: Square = num*num
Step 4: Print Square
Step 5: End
Flowchart

2. Draw a flowchart to find the greatest number among the 2 numbers.


Algorithm
Step 1: Start
Step 2: Input first number a
Step 3: Input first number b
Step 4: Check if a > b
Step 5: Print a
Step 6: Else
Step 7: Print b
Step 8: End
Flowchart

2. Draw a flowchart to check whether the input number is odd or even.

Algorithm
Step 1: Start
Step 2: Input number num
Step 3: Check if num%2== 0
Step 4: Print Even
Step 5: Else
Step 6: Print Odd
Step 7: End
Flowchart

Conclusion
Flowcharts are simple diagrams that map out a process, so that that can easily be
communicated to other people. They are typically used to define and analyze a
process, build a step-by-step picture of it, and then standardize or improve it.
To draw a flowchart, identify the tasks and decisions that you make during a
process, and write them down in order. Then, arrange these steps in the flow chart
format, using the appropriate symbols.
Finally, check and challenge your flowchart to make sure that it accurately
represents the process, and that it shows the most efficient way of doing the job.
Pseudocode

Introduction
As developers, programmers or data scientists, we often go through many stages,
from getting an idea to reaching a valid, working implementation of it. We need to
design/ validate an algorithm, apply it to the problem at hand, and then test it for
various input datasets. In the initial state of solving a problem, it helps a lot if we
could eliminate the hassle of having to be bound by the syntax rules of a specific
programming language when we are designing or validating an algorithm. By
doing this, we can focus our attention on the thought process behind the algorithm,
how it will/ won’t work instead of paying much attention to how correct our syntax
is. Here is where pseudocode comes to the rescue. Pseudocode is often used in all
various fields of programming, whether it be app development, data science, or
web development. Pseudocode is a technique used to describe the distinct steps of
an algorithm in a manner that is easy to understand for anyone with basic
programming knowledge.

Meaning and Definition of Pseudocode


Pseudocode is a term which is often used in programming and algorithm based
fields. It is a methodology that allows the programmer to represent the
implementation of an algorithm. Simply, we can say that it’s the cooked up
representation of an algorithm. Often, algorithms are represented with the help of
pseudo codes as they can be interpreted by programmers no matter what their
programming background or knowledge is. Pseudo code, as the name suggests, is
a false code or a representation of code which can be understood by even a
layman with some school level programming knowledge. It’s simply an
implementation of an algorithm in the form of annotations and informative text
written in plain English. It has no syntax like any of the programming languages
and thus can’t be compiled or interpreted by the computer. Although pseudocode is
a syntax-free description of an algorithm, it must provide a full description of the
algorithm’s logic so that moving from it to implementation should be merely a task
of translating each line into code using the syntax of any programming language.

Reasons for using Pseudocode


1. Better readability: Often, programmers work alongside people from other
domains, such as mathematicians, business partners, managers, and so on.
Using pseudocode to explain the mechanics of the code will make the
communication between the different backgrounds easier and more efficient.
2. Ease up code construction: When the programmer goes through the
process of developing and generating pseudocode, the process of converting
that into real code written in any programming language will become much
easier and faster as well.
3. A good middle point between flowchart and code: Moving directly from
the idea to the flowchart to the code is not always a smooth ride. That’s
where pseudocode presents a way to make the transition between the
different stages somewhat smoother.
4. Act as a start point for documentation: Documentation is an essential
aspect of building a good project. Often, starting documentation is the most
difficult part. However, pseudocode can represent a good starting point for
what the documentation should include. Sometimes, programmers include
the pseudocode as a docstring at the beginning of the code file.
5. Easier bug detection and fixing: Since pseudocode is written in a
human-readable format, it is easier to edit and discover bugs before actually
writing a single line of code. Editing pseudocode can be done more
efficiently than testing, debugging, and fixing actual code.
Main construct of Pseudocode
The core of pseudocode is the ability to represent 6 programming constructs
(always written in uppercase): SEQUENCE, CASE, WHILE, REPEAT-UNTIL,
FOR, and IF-THEN-ELSE. These constructs — also called keywords —are used to
describe the control flow of the algorithm.
1. SEQUENCE represents linear tasks sequentially performed one after the
other.
2. WHILE a loop with a condition at its beginning.
3. REPEAT-UNTIL a loop with a condition at the bottom.
4. FOR another way of looping.
5. IF-THEN-ELSE a conditional statement changing the flow of the
algorithm.
6. CASE the generalization form of IF-THEN-ELSE.

Although these 6 constructs are the most often used, as you can theoretically use
them to implement any algorithm. You might find yourself needing some more
based on your specific application.

Rules for writing Pseudocode


When writing pseudocode, everyone often has their own style of presenting things
out since it’s read by humans and not by a computer; its rules are less rigorous than
that of a programming language. However, there are some simple rules that help
make pseudocode more universally understood.
1. Always capitalize the reserved commands/keywords.
2. Have only one statement per line.
3. Indent to show hierarchy, improve readability, and show nested constructs.
4. Always end multi line sections using any of the END keywords (ENDIF,
ENDWHILE, etc.).
5. Keep your statements programming language independent.
6. Keep it simple, concise, and readable.

Pseudocode Examples
1. Write a pseudocode that reads two numbers and multiplies them together and
print out their product.
READ 𝑛𝑢𝑚1 , 𝑛𝑢𝑚2
SET product to 𝑛𝑢𝑚1* 𝑛𝑢𝑚2
Write product

2. Write a pseudocode that tells a user that the number they entered is not a 5 or a
6.
READ num
IF (num = 5)
WRITE "your number is 5"
ELSE IF (num = 6)
WRITE "your number is 6"
ELSE
WRITE "your number is not 5 or 6"
END IF

3. Write a pseudocode that performs the following: Ask a user to enter a number. If
the number is between 0 and 10, write the word blue. If the number is between 10
and 20, write the word red. if the number is between 20 and 30, write the word
green. If it is any other number, write that it is not a correct color option.
WRITE "Please enter a number"
READ color_num
IF (color_num >0 and color_num <= 10)
WRITE blue
ELSE IF (color_num >0 and color_num <= 10)
WRITE blue
ELSE IF (color_num >0 and color_num <= 10)
WRITE blue
Else
WRITE "not a correct color option"
END IF

You might also like