Transcripts
1. Introduction: Hi friends, My name
is obeyed Qazi, and today I'm gonna teach
you about flowcharts and pseudocode from scratch, which means I will teach
you from basics to advance. So let's see what do we
learn in this course? You will learn about
flowcharts and pseudocode. Why is it useful? What was it mean purpose
in programming language? Okay, so once you're done, Let's dance flowcharts
and pseudocode. You will easily understand any programming language
because it builds logic. Okay, To understand
programming language. Okay, so let's see what you
will learn in this flowchart. You will learn how to
solve the problems. Using flowchart. You will be able to identify
the symbols in flowchart. Flowcharts have many symbols. I will teach you about
each and every symbol. In subsequent chapters. You will know how, you will know which tools we'll
be using problem-solving. You will learn about the lipid adding
processing flowchart, you're repeating process
means for loops, while loops repeat until
loop, important in flowchart. Okay, so let's see what you
will learn in pseudocode. You will learn how to solve arithmetic problems
using the pseudocode. You will know how to use
operators in pseudocode. Pseudocode has three
main operators. That is arithmetic operators, relational operators
and logical operators. You will know what is algorithm and you will know how to use a medial variables and
constants in pseudocode. You will identify. You will be able to identify or define
datatypes in pseudocode. So before we actually
start writing a program, we need to drive the procedure
to solve the problem. There are v is available to drive a solution to
a given problem, such as flowcharts
and pseudocode. Let's see what is the flow time. Flow chart is a
graphical representation of the steps to be taken. Or you can say, steps to be followed for
solving a problem. It consists of a set of symbols. Each symbol represents
a specific activity. For example, I have
drawn a flowchart. To show you an example
of the flowchart, we see the first
symbol is called. Let's start simple. It's very important
in flowchart. So if this symbol is not
there in your flowchart, then a flowchart is incomplete. Okay? This symbol is
called input symbol. Okay? It accept the number
from the user. Okay? Now the third, or we can say fourth symbol is
called as processing. Similarly, nepal
example, you want to accept the two
numbers and then you want to add two numbers, right? Okay. Then you want
to add two numbers. Your antigen will be done
in processing symbol. Display output. We will use outputs in. This symbol is called
as stock symbol, keep, Remember stop
symbol and start symbol. Both are seen and both are very important
in the flowchart. Let's see some advantages
of flowcharts. Flowcharts and analyzing
the problem effectively. The flowchart as a guide during the program
development phase. Flowchart helps easy debugging
of logical programs, or you can say logical errors. The flowcharts helps
in mentoring programs. Well, let's see what you
will learn in pseudocode. Pseudocode is a
comprehensive depiction of the solution to the
problem and provide programmers detailed
template for writing instructions in a specific
programming language. So for example, you want to write the program in C, C plus, plus C-Sharp or Java or any other programming
language, okay? Then you must write
pseudocode for the program. It will become much easier
to write a program. Okay, so once these
pseudo code is verified, it can be converted
into a program using the vocabulary and syntax
programming language. Okay, so let's learn
its advantages. Okay? So it is easier and
faster to write as it uses English like statements. It does not need
to be rewritten if any changes are made
because it's step is independent and maybe more defined without altering
the other steps, can be converted to a program using a programming language. Okay, so let me explain
you with an example of this is a 0 basically in which
we are comparing two numbers to know whether
they are equal or not. So basically we have written a pseudocode in which we
are comparing two numbers. So as you can see, number one, we have five and in them to v hat by these
numbers are equal. Okay? So it'd be executed
the first block, which is called as
begin block, okay? And it will print the
numbers are equally. In second pseudocode. It has y and in numb to it has six between you go
into the else block. Okay? Because the numbers
are not equal and it will print
the numbers are. Okay. I hope you got it. Whatever I have
explained you till now. And if you didn't understand anything, right, don't worry. In this course, I
will be explaining you with the examples, with all examples of
based on the real-life. Okay, So start learning now. Take care. Thank you.
2. Input Process and Output: Hello friends, welcome
to our first chapter, which is input,
process and output. Let's see what is input process
and output in computers. Computer is used for storing
and processing information. Computers follows
principle of input, process and output
for any problem. To perform this input process
and output activities, computers need a set of
instructions called a program. Let's see an example of
input, process and output. You might have noticed
computers being used at airline
reservation counters, shops, restaurants, and
various other locations. At each of these locations, user enter some values
in the computer, and the computer
generates an output which is other displayed on the computer screen
or printed on paper. Let us consider the example of airline reservation counter. When you want to reserve a
seat on a particular flight, you provide information
about your requirements, such as destination, date,
time, offer departure. The class in which
booking is required. The reservation counter enters this information in a computer. The details regarding
the availability of tickets are then
displayed on the screen. The preceding
automated process not carried out as one activity. It is broken down into a set of activities that are carried
out in separate phases. Let us see what are the phases involved and the processes followed for each of the tasks. To understand what
happens when you enter some values
in the computer. Let us break the entire set of activities into separate phases. In the first phase,
flight requirements are keyed into the computer. This phase is called
the input phase. The flight information
is then processed. Determine whether seats are available on the
particular flight. This phase is known
as the process phase. Once the processing is complete, the result is displayed on the computer screen indicating the status of seat availability. This phase is called
output phase. The output phase. The cycle of activities
performed by a computer is known as z, is input, process. And output cycle. Inflammation escaped
into the computer. It will then process
and the result will be shown or display
on the screen. Now, computer consists of several components
such as keyboard, a mouse, a monitor, or a printer, and a central
processing unit or CPU. Each competent participants
in either one of the input processes
or output faces. For example, the keyboard and
mouse are used for input. The CPU and the memory inside the CPU are used for processing. The monitoring printer
are used for output. This is a figure of input
processing output cycle. Now in next chapter, I will explain you algorithm, which is based on input
process and output. Didn't understand this
input processing output. Don't hesitate to
ask me questions. Thank you.
3. What is Algorithm: Let's see what are the tools
used in problem-solving. Before we actually start
writing a program, we need to drive a procedure
to solve the problem. There are various
tools available to drive a solution to
a given problem, such as algorithm,
flowcharts and pseudocode. Let's first see what
is an algorithm? An algorithm is a sequence of steps required to
solve a problem. It is a list of well-defined instructions
to solve a problem. Now suppose, for example, that we have to call someone. To call someone, we have
to do the following work. First, we will check where
the phone is turned on. Or node means dial
tone is coming or not. The dial tone is coming. Then you have to dial
the phone number of the person with
whom you want to talk. After dialing the phone
number of the individual, you will have to wait
on the phone ring. Once it started drinking. The person you are
calling a tensor call, then you can start talking. From this group of steps. We can understand that if
we want to call someone, we have to follow
certain number of steps. Now we can change these steps. Now what we can leave any step. If we ignore any of these steps, then we can not talk
to the target person. The problem may not
get dissolution. So for example, if we did it step two from the
falling algorithm, then this will be called as
incomplete algorithm because dialing a number is an E is N. Very important. Step to call someone. Let's see. Rules of algorithm. Algorithm will have
five characteristics. First is an algorithm ends
after a fixed number of steps. It stepped in. An algorithm clearly specifies the
action to be performed. The steps in an algorithm
specified basic operations. These operations could
include calculations, input, output operations,
and comparisons. An algorithm excepts input
data in a defined format. Before it can be processed. An algorithm generates
one or more outputs. After the input is processed, the resulting
information termed as output can be
displayed or stored. For future difference. Now consider another example that you want to withdraw a
required amount from an ATM. The algorithm for this problem
is, start the algorithm. Go to any local ATM, insert swipe, swipe
your ATM card. But as the language button
that you want to choose, enter the PIN code number. Press the account
type savings occur in button from which you
want to withdraw the money. The cash withdrawal burden. Enter the amount
you want to redraw. Collect the amount
from the ATM machine. Click this statement. You
can make your ATM card. Now computer follows input. An algorithm follows. In computer, an
algorithm follows input process and output
cycle to solve a problem. Here, the input to withdraw a required amount from an
ATM will be the ATM card, the pin code number, and the amount that
you want to redraw. These inputs are then accepted in the process of withdrawing
the amount takes place. At the end of the process, the amount, which is the
output, is withdrawn. Consider another algorithm that displays the product
of two numbers. First step will be to
start the algorithm. Second step will be to
get the first number. First step will be to
get the second number. Fourth step will be
to multiply that two numbers in the fifth will be to display the result is six. And the algorithm,
as you can see, first number is four,
seconds is nine. And when we went to
this port number, we got the result 36. For example, if we delete step
four from this algorithm, this algorithm will
become incomplete. Algorithm must be in sequential, and it must complete every step. To solve a problem. I'm giving you two more
questions to solve. And if you found
any difficulties in solving these questions, then please ask me. I will definitely help you. In next chapter, we will
see what is flowchart, which is based on algorithm and input
process and output cycle.
4. What is Flowchart: Let's see what this
flowchart flow chart is, a graphical representation
of these steps to be followed for
solving a problem. It consists of a set of symbols. Symbol represents a
specific activity. Let's see what are the
symbols in flowchart. This symbol is
called input symbol. For example, you want to
accept a number from the user. You will accept the number, or you want to prompt the user to enter a
number in the system. You will do with input symbol. This symbol is called
processing symbol. For example, you want to do calculations such as addition, subtraction, division,
multiplication. So this will be done
in processing symbol. This symbol is Carlos,
output symbol. For example, you want to show or display the result of
addition of two numbers, then you have to
use output symbol. There is this symbol is
called decisions in Berlin. For example, you want to know whether the condition
is true or false, then you can check it
in condition symbol. This symbol is called a
procedure or subroutine symbol. This is called as flow lines. It is used to connect the
steps of the flowchart and indicate the sequence in which the steps are
to be performed. For example, if you want
to connect input to processing and
processing to output, we will use flow lines. Now this symbol is known as
initiative or terminator. It indicates the beginning
or end of the flowchart. This symbol is very important in flowchart because
without this symbol, you can not start
or stop flowchart. This symbol is known
as on-page connector. It is used to connect one
step in the flowchart to another step
on the same page. This is known as
off-page connector. It is used to
connect one step in the flowchart to another
step on a different page. Please don't get
confused between on-page and off-page connector. On-page connector is used to connect one step
on the same page. And off-page connector
is used to connect one-step or another
step on different page. This symbol is known
as annotation. This is used to input
comments on our flowchart. Comments can be inserted in flowcharts to provide
explanation of the steps. There are some
rules in flowchart. Let's see what it is
that the logic of a flowchart should be represented
using standard symbols. The flowchart should be clear, precise, and easy to follow. The flow chart should have only one start point, end point. The start and stop
symbols should have only one single flow line. It is useful to test the logic of the flow
chart by testing the flowchart using
some temple values. Next session, I will teach
you how to draw flowchart. And what is
conditional execution. How to implement rehabilitative
processing flowchart. If you didn't understand
anything in this lecture, please don't hesitate to ask me. Thank you.
5. Flowchart Continued: Now that you know about the various symbols
used in a flowchart, let us consider
some examples where we use flowcharts
to solve problems. Now consider the example of withdrawing and
amount from an ATM. But before we start
drawing flowchart, we must write its algorithm. Because algorithm will
simplify your flowchart and it will show you step-by-step
process to solve your problem. Let's see It's algorithm. You will go to an ATM
to withdraw amount. You will first insert
a swipe your ATM card. But remember, the
most important step of algorithm is to write start the algorithm statement
while starting the algorithm and the algorithm after finishing your algorithm. Let's come back to
our loop algorithm. We will first start
the algorithm. Then we will go to, you will go to any local ATM, will insert, swipe
your ATM card. Then you will press
the language button that you want to choose. Then enter the PIN code number. Then press the account type, whether it is saving or current button form which you
want to withdraw the money. Then press the cash
withdrawal button, enter the amount you
want to withdraw. Colleague the amount
from the ATM machine, collect the statement
from the ATM machine, click your ATM card. And then the algorithm. Now let's see it's flowchart. As you can see, start symbol, which is the most important
symbol in flowchart. But let me tell
you one thing that before we start with flowchart, I will recommend you to learn by hardly
symbols of flowchart, which I've taught you
in our last lecture. Let's continue with flowchart. We will use start symbol first. Then we will use
processing symbol to go to any local idiom. Then you insert an ATM card, which will come in input symbol. Because you are entering
value in system. Or you can say you are giving
information to the system. Then press the language button, which will also come
in input symbol, because we are entering
information in the system. Then enter the PIN
code offer ATM card. It will also come
in input symbol because we are entering some
information in the system. So formula, you're going
to understand that if you enter information in the
computer, it will come in. Input symbol. This is
off-page connector. We use this because we are
connecting another flowchart. On. Next slide. Select your account type
savings or current. And then press the
withdrawal button. Anterior amount,
colleague amount. Your clicker amount statement
is in output statement. So the output symbol, because we are not entering
any value in a DC machine, now we are giving command. We are collecting
amount from ATM. So it will come
in output symbol. Then colleague your ATM card, and it will also come
in output symbol. Now we have completed our tags. So we will stop with the
flowchart width stop symbol. Consider one more example
where a number is accepted by us and
incremented by one. And the result will be display. Means we have to
accept the number, suppose five, and we
have to add one to it. Then we have to
display the result. Let's say it's flowchart. First we will start the flow
chart with start symbol. The next epoch number, which
will be in input symbol. Then add one to it, which will be in
processing symbol. Now tell me why this statement
is in processing symbol. If you know the answer, it's good, it's not. Then let me explain you. This is in processing
symbol because we are doing addition at here. It means whenever
you do additions, multiplications are
any calculations. Then that calculation
will come in processing symbol and
do display the result. We will use output symbols. As you can see, at the result of adhesion
is in output symbol. After completion,
completing our tags, we will stop the flow chart. If you didn't
understand anything, then please don't
hesitate to ask me questions. Thank you.
6. Tools used in Problem Solving: Let's see what are the tools
used in problem-solving. Before we actually start
writing a program, we need to drive a procedure
to solve the problem. There are various
tools available to drive a solution to
a given problem, such as algorithm,
flowcharts and pseudocode. Let's first see what
is an algorithm? An algorithm is a sequence of steps required to
solve a problem. It is a list of well-defined instructions
to solve a problem. Now suppose, for example, that we have to call someone. To call someone, we have
to do the following work. First, we will check where
the phone is turned on. Or node means dial
tone is coming or not. The dial tone is coming. Then you have to dial
the phone number of the person with
whom you want to talk. After dialing the phone
number of the individual, you will have to wait
on the phone ring. Once it started drinking. The person you are
calling a tensor call, then you can start talking. From this group of steps. We can understand that if
we want to call someone, we have to follow
certain number of steps. Now we can change these steps. Now what we can leave any step. If we ignore any of these steps, then we can not talk
to the target person. The problem may not
get dissolution. So for example, if we did it step two from the
falling algorithm, then this will be called as
incomplete algorithm because dialing a number is an E is N. Very important. Step to call someone. Let's see. Rules of algorithm. Algorithm will have
five characteristics. First is an algorithm ends
after a fixed number of steps. It stepped in. An algorithm clearly specifies the
action to be performed. The steps in an algorithm
specified basic operations. These operations could
include calculations, input, output operations,
and comparisons. An algorithm excepts input
data in a defined format. Before it can be processed. An algorithm generates
one or more outputs. After the input is processed, the resulting
information termed as output can be
displayed or stored. For future difference. Now consider another example that you want to withdraw a
required amount from an ATM. The algorithm for this problem
is, start the algorithm. Go to any local ATM, insert swipe, swipe
your ATM card. But as the language button
that you want to choose, enter the PIN code number. Press the account
type savings occur in button from which you
want to withdraw the money. The cash withdrawal burden. Enter the amount
you want to redraw. Collect the amount
from the ATM machine. Click this statement. You
can make your ATM card. Now computer follows input. An algorithm follows. In computer, an
algorithm follows input process and output
cycle to solve a problem. Here, the input to withdraw a required amount from an
ATM will be the ATM card, the pin code number, and the amount that
you want to redraw. These inputs are then accepted in the process of withdrawing
the amount takes place. At the end of the process, the amount, which is the
output, is withdrawn. Consider another algorithm that displays the product
of two numbers. First step will be to
start the algorithm. Second step will be to
get the first number. First step will be to
get the second number. Fourth step will be
to multiply that two numbers in the fifth will be to display the result is six. And the algorithm,
as you can see, first number is four,
seconds is nine. And when we went to
this port number, we got the result 36. For example, if we delete step
four from this algorithm, this algorithm will
become incomplete. Algorithm must be in sequential, and it must complete every step. To solve a problem. I'm giving you two more
questions to solve. And if you found
any difficulties in solving these questions, then please ask me. I will definitely help you. In next chapter, we will
see what is flowchart, which is based on algorithm and input
process and output cycle.
7. Conditional Execution in Flowchart: Let's see what is conditional
execution in flowchart. That are various situations
where they need to perform an action
based on a condition. This is known as
conditional execution. Step by step process of solving a problem is not
always sequential. At times it involves
making decisions and repeatedly performing
a set of steps. Let us see how conditional entropy due process can be
depicted in a flowchart. First, we will see
conditioning process than it. Next lecture we will see
a repetitive process. Consider an example
where we need to determine whether a
number is even or odd. So we will start a
flowchart, but start symbol. Then we will accept a number. For example ten,
then DY DT by two. In processing symbol and check the condition
in condition symbol. Now we have to check whether
remainder is 0 or not. If the remainder is 0, then it will display
the number is even and it will
stop the flowchart. And if the remainder
is not equal to 0, then it will display
the number is odd and it will stop the flowchart. Let's consider another
example in which we have to find the largest of the three numbers
entered by a user. Let's see, it's flowchart. Start a flowchart
with start symbol, also accepted three
numbers in input symbol. Then we will check the condition
in conditional symbol. We will check whether a
is greater than or not. If not, then it will execute
condition next to it. That is, whether B is
greater than C to C or not. If yes, then it will display B. If not, then it will display c. Now, if a is greater
than b becomes false, then it will execute condition
which is below to eat. That is, it will check. Another condition,
one more condition, that a is related to c or not. If that condition becomes true, it will display a. If not, then it will display C and it will stop
the flowchart. You get me. We didn't
get me. Please. Don't hesitate to ask me. Now I am giving you
one more question to solve it your own. Let's see the caution that well, let's see the question. But the falling
marks are given to students depending on the
grades they have scored. Grid a will be excellent, Great, be very good. And great. C is good. You have to solve this problem. If we didn't, it will dissolve, then you can ask me. I will definitely
help you. Thank you.
8. Repetitive Process in Flowchart: Let's see what is rehabilitative
process in a flowchart. Programs involve certain
processes that need to be repeated either for a definite or indefinite
number of times. Consider an example where we
need to draw a flowchart to calculate the sum of n
numbers entered by the user. You will start the flowchart. And you will take two variables, that is y and sum. Then add. Why? With one that
is 0 plus one will, one will get stored in y. And not the value
of y becomes one. So the value of 0, sum is 0. So we'll add 0 with one. And again, we will
get the result that is one and we
get stolen some. Then we'll check a condition whether Y is equal to N or not. This condition becomes false because now the
value of y is one. So the loop will continue until the value
of y becomes ten. Then once it becomes ten, it will display the
sum of n numbers. The loop will get stopped. At. The next slide. I will explain you about
pseudo-code. Thank you.
9. Pseudocode: Let's see what is
the pseudocode. Pseudocode is used to
represent the logic of the solution to a problem. Once the pseudocode is verified, it can be converted
into a program using the vocabulary and syntax of a
programming language. Let's certain keywords in
pseudocode. Let's see. It. One-by-one. Double black slash represents a comment, entry. Begin or end represents a block, which is used to
start and pseudocode, except it is used
to accept input. Compute it is, is to calculate the result
of an expression. Display. It is used to
display the output. If else, used to make decisions. For index, used to isolate a set of statements called
substituting, used to invoke some pollutants. Let's see It's
explanation one by one. Bean or, and these keywords are used to start and finish
pseudocode is that told you? Begin is a first-line. And the last line of pseudocode. Except this keyword is used to obtain an input from a user. Display. This keyword is used to represent a result or an output. If else does, keywords are
used in decision-making. Double backslash is
for comment, do while. For repeat, FOR loop, do-while. Loop. To loop represents this
all represents the loop. This is an syntax of pseudocode. So this is pseudocode to x. To add two numbers. Adding two numbers,
we will accept the two number with
except keyword. You will, then you will add these two numbers with compute keyword and some S variable. And the display, the output. We will use display keyword. So it will display the result. For Andy pseudocode. You will use and
keyword. Next slide. I will explain you about variables and
constants is new code, datatypes in pseudocode and some more examples
of pseudocode.
10. Conditional Constructs in Pseudocode: Let's see what is conditioned. Consult. In pseudocode. Many problems require
decisions to be made. All decisions may
or may not state and action to be taken if
the condition is false. The following types of
decision-making constructs can be used in and see the code. If constructs and switches,
switch case constructs. Post. Let's see. If construct. Simple. If construct, if the conditions
specified is true. The statements contained within the if block are executed. Pseudocode segment
to represent this simple if constructs
are as follows. If you will, then we will check the
condition, this bracket. Then the condition becomes true. It will execute begin Brock
and provides the loop. The construct will
exit from the program. Switch gets construct
enables you to make a decision by selecting
from number of choices. The pseudocode of
this switch gears construct is as follows. Switch expression begin
k is constant one. Execute these statements. Break. Gas constant is two. Now let me explain
this with an example. The M is writing
the algorithm for automated telephone
call transfer. To wait Is departments of the
company, such as marketing, finance, customer care,
resources, and information. You have to write the pseudocode for the following problem. Start first. We'll make a flowchart. For particular pseudocode. We will start a flowchart. We start symbol. We will accept in a variable
called data type numeric. So we will ask the user to enter the number
from one to four. Then the number
will get stored in n. And then we will
check condition whether that n is
equal to one or not means the number entered
by the user is one or not. If it is one, then called WeTransfer to
marketing department, if no, then it will check another
condition that is whether n is equal to two unknown number entered by the user
is equal to a naught. If it is Dan, It's called WeTransfer
to finance department. If not, then you reject
third condition. Whether the number entered
by the user is three or not. If it is three, then transferred call to
customer CAD department. If it is not in reject
the fourth condition. If that become true, then it will transfer
call to HR department. If not, then the loop will stop. So let's say it's pseudocode. So independent in pseudocode, the value of the
variable and call is matched with a constant value, is matched with
the constant value specified with the
first case statement. If the value of n called
matches these statements, in that case block are executed and the call is transferred
to the marketing department. Otherwise, the control passes
to the next case statement. This process continues until the value of n call matches
with one constant value, or it reaches the default case. The customer controlled
reaches the default statement, the call is transferred to
the information department. No idea. We have three types
of constructs. That is simple if conserved. If else construct a
nested if else construct. We already saw if
simple, if construct. Now we will see if else
construct in the if else construct the statements
within the if block are executed for
condition being true. And this statement is
within the else block are executed for the
condition being faults. You can see if condition we can, we will check the
condition in this bracket. If the condition becomes true, it will execute first, begin block, the condition
becomes false to execute. Second building block,
which is in else. Let's see an example of declared variables
with num1 and num2. And its type is numeric. Then accepted the two numbers. And then we will check the
two numbers. If condition. If the numbers are equal, then it will display
the numbers are equal. Otherwise it will
grow in Else block, which will display the
numbers are not equal. Now let's see what is
necessarily pulse construct. Pseudocode needs to
be evaluated based on the condition within
another conditions. In that case, you can use an if else statement within
another if else statement. Let me give you an example. This isn't syntax of
nested if else construct. First we will check
the condition. If the condition becomes true, it will print the desert. And if the second
condition becomes true, then it will print
in Else block. And in third, in
second L is block. You can see the
statements to be executed based on about two conditions. Whatever conditions the
statement will be executed. Give you an example of accepting two numbers and print the
larger of two numbers. For this, we will
take two variables, that is num one, num two. And we will check whether the number is equal
to num two or not. If it's equal to num two, then it will display
the numbers are equal. It will check. And the condition whether num one is greater
than two, num two. If it is greater
than number one, if the money is
greater than num two, then it will display
number one else. It will display num
two. As you can see. We have to, if else in
one pseudocode program. So this is called
necessarily feels construct. So if you didn't
understand anything, please don't hesitate to ask me. Thank you.
11. Data Types in Pseudocode: Let's see what is
the return types in pseudocode and how to
assign values to variables. So there are two types of
data types in pseudocode. First is pneumatic and second
is character and numeric. We can store only numbers. And these variables can be
used in arithmetic operations. The variables which
is declared as numeric datatype will be used, can be used in
arithmetic operations such as additions,
multiplications, divisions. And character variables can contain any combination
of letters, numbers, and special characters, but can not be used
for calculation. There are some rules to follow. Before you name a variable. First is the first letter
of the variable may indicate data type used. For example, it
can be either see or n to indicate a
character or numeric variable as in C name and n h. The variable names should clearly
describe the purpose. For example. And score is a numeric
variable to store the score. The variable names should not
contain an embedded space or symbols such as exclamation
mark and symbol M. For symbol, you can use an underscore when space
is required in a variable. Name, for example. And basic underscore salary. It will store salary in numbers. If a variable name consists of multiple words without
spaces in-between, capitalize the first letter
of each word for readability. Some examples are n total
score and n sum of squares. Now you know the rules
for naming variables. Let's see how to assign
values to variables. Any variable needs to be
assigned a value before its use. This is to ensure that
the memory space located to the variable is
initialized with a value. With a valid value. The variables can be assigned values in the
following two methods. First is direct assignment. Second is Except Statement. In the direct assignment method. Values can be assigned
to variables using the equal to sign as shown in the following syntax.
Variable name. It's equal to value. Whatever value will be there, it will get stolen
variable name. Let's see an example
of direct assignment. Here. We are taking three variables, which is height, h and cold with datatype numeric and
character respectively. Assigning value once and 172 to n height with the equal to sign. So at the time memory
location of a computer will know that value 172 is
getting assigned to height. And it will allocate
a memory location and height variable with
unique address of memory. Location means it will assign a unique address of memory location of
n height variable. And this is applicable to
n h and c code readable. Now let's see, Except Statement. Values can be
assigned to variables except statement as shown in the formula syntax,
except variable name. Indirect statement, assignment. We saw that we used equal to sign to store the
value in the variable. But here in except statement, we are using except keyword. Except keyword will
directly take input from the user and the value will
be assigned to variable, whatever will be the
name of the variable. Let's see one more
example where we have to accept two
numbers from user, and then we have to
display their sum. First we will declare
three variables. That is an num one, num two, and some with
numeric datatype. Then we will prompt
the user to enter the first number and it
will get stored in num one. Then we will from user to enter the second number and
it will get stolen. And num2 and the addition of both the numbers
will get stolen and some variable D Got it. So if you didn't get anything, what I explained just now, then please don't
hesitate to ask me.
12. Variables and Constant in Pseudocode: Let's see what is an variables and
constants in pseudocode. A variable refers to
the memory location whose value changes during
the program execution. Constant refers to
the memory location whose value does not change
during the program execution. Now let's see how it works. When a user enters a
value that is stored in a specific location within
the memory of the computer. This memory location is
given a user-friendly name, which is known as
variable or constant. For example, we have
a value which is ten, and it will get
stored in num one. But what a processor will do, but what your
processor will do is it will create different
memory location for value ten, which will store only
one value at a time. But it can vary throughout
the program execution. You can see, however, a constant defers to the
memory location that holds a value which remains fixed throughout the
program execution. It refers to address
of memory location. Let me explain you in detail. Consider an example of a program that accepts two numbers
and displays the sum. This program, there's
three variables stored in the embers
entered by the user and when to store the
sum of the two numbers. Each of the variables
will map to a specific memory address. But the given scenario, the following variables
are declared. Num one, num two, and some. You can say n sum.
With numeric datatype. The variable and num. One stores the first number
entered by the user, which is ten, and maps to
the memory address 4560. The variable num to store the second number entered
by the user, which is 15. And map to the memory
address 456 to the variable. And some stores the sum
of the two numbers, which is 15, sorry, 25, and maps to the
memory address 4564. Address of memory location is constant and num
one is variable, because address of memory
location will not be changed unless until the name of
the variable get changed. During computation, the
program will refer to the variable num one to retrieve the first number
ten entered by the user. And the variable. And num2 to retrieve the second number 15
entered by the user. The variable. And some will store the
sum of the two numbers. Now there are two golden
rules in variables. You need to declare a variable before using it in a program. The variable, sorry, the declaration of
a variable assigns a name to the variable and specifies the type of
data the variable can store. You need to declare a
variable before using it. In a program. For example, numeric and
num1 and num2 and N sum. This d variables are declared. Before we write our program. The declaration of a variable assigns a name to the variable, and it specifies the type of
data the variable can store. We are assigning a
name to the variable, and then we are assigning
data type to a variable. So we have to do this,
right, available. Or you can say to
declare a variable. So if you didn't
understand anything, please don't hesitate
to ask me. Thank you.
13. Operators: Let's see what is operators. Programs are required
to perform a lot more than just simple input, output, input, and
output operations. All computer languages provide tools for some
predefined operations. These tools are
known as operators. The operators are categorized
in the following ways. First is add the cooperator. Second is a relational operator. This logical operator. Let's see each
operator one by one. The arithmetic operators are used for computation purpose. Example plus minus
multiplication, division. Modular arithmetic operators. The more dilute divides
two numbers and returns the remainder modulo symbol divides two numbers and
returns the remainder. Relational operators. Second Disney second operator. Relational operators are used to compare two variables
or constants. There are six
relational operators. Firstly is less than, second is, firstly
is greater than, second is less than. Third is less than,
greater than equal to. Four, is less than equal to, is equal equal to
66 is not equal. You can see now when we are checking the
condition within num one is equal to num two. Num one is greater than num two. Num one is less than num two. Num one is not equal to num two num one is less than
equal to num 2. Third, operators,
logical operators. Logical operators
are used to combine expression containing
relational operators. The following table describes the evolution of the various
lobes logical operators. Assuming that the value
of a variable number1 is to that of variable
num two is six. Let's see. Each operator
is an operator, N operator, all the
conditions are met. It will be true. For example, we have a zoom. The value of num one is two. The value of num two is six. So let's check the condition. In example. With an example. Then num one is
equal to equal to two and num two is less than. Num two is greater than four. Is this condition is true? Yes. The condition becomes true. So the result will be true. If any of this condition
becomes false, then N operator will terminate. Means it will not execute. For an operator. Both the condition
should be true. Second is OR operator. In our operator, if
anyone condition met, it will print true. For example, of first
condition is true. That is num one is
equal to equal to two. But second condition
number two is less than five is false because six is greater than six. And idea, it tells that six
is num two is less than five. So this condition becomes false. But it will print true. Because this index
of our operator is that only one condition
should be true. Only one condition
should be met through. Third is NOT operator. Not operator. Both the
conditions should be false. As you can see, num two is
less than equal to five, which is false because we have assumed that the
value of num two is six. So six is not less than five at your
condition becomes false, so it will print two. Let me explain you operators. With an example where
a user is given a discount on a purchase based on the following conditions. If the D is not a Sunday, if the purchase amount is
greater than $5 thousand. The falling for flowchart
depicts the solution to dy. Preceding problem. You have to draw a flowchart where a user is
given a discount on purchase if the day on which
he or she is purchasing. Purchasing should not be
sin D and E are cheap. Purchase. More than $5 thousand than their discount
will be calculated. It's flowchart. Start a
flowchart with start symbol. Except two variables with
numeric data type, that is n, the amount of check
the condition in decision-making symbol is
not ND is equal to Q2. Sunday. Will check whether
d is Sunday or not. If it is Sunday, then it will terminate and
it will stop the flowchart. And if the D is not Sunday, then it will check
next condition which is in an operator, but the amount is greater
than 5 thousand or not. If this condition becomes true, then it will execute
next step that is, calculate discount and
it will flow chart. Suppose if this
condition becomes false, means the amount year she purchased is less
than $5 thousand, the flowchart will terminate. So if you didn't
understand anything, please don't hesitate to ask me. Thank you.
14. Iterations: Let's see what is an
iteration in pseudocode. Sometime programs
become lengthy, not only because of complex
decision-making constructs, but also because they
are designed to perform tasks that are the
protective in nature. It is the length of code in such a situation or iterative
constructs can be used. One of the most important characteristics of a computer is its ability to execute a series of instructions
repeatedly. This ability of the computer
gives you a flexibility to control the number of times
attacks to be repeated. Three types of
identity constructs. That is, first is while loop. Second is the repeat
until loop. And 30s. Let's see. First for loop. The for loop construct
provides a compact, compact way of specifying
these statements that control the repetition of
these steps within the loop. For loop is classified as
I iteration statement. The for loop consists of
the following three parts. First is initialization
expression, second is evaluation expression. Third is increment
decrement exploration. In this initial
addition expedition, the numeric variable is initialized using
a variable value. Initialize the next fission. And numeric variable is
initialized using a value. In evaluation expression. The condition is tested at the beginning of
iteration of the loop. When the expression evaluates
false, the loop dominates. This is an very important
expression in follow. This an increment,
decrement expression. In this, the value
of the variable is increased or decreased intake. So for-loop me show you in
a flowchart of for loop. And it's flew off. That is flow of for loop. First, it will initialize
a valued condition. Then if the condition is true, then it will enter in
the body of the loop. If condition becomes false, then it will exit from the loop. After executing the
body of the loop, it will execute increment. It will do increment or
decrement of variable by one. Whatever the value is
specified in the loop. Then it will again go
to valued condition. I know it will continue looping until the
condition becomes false. Once the condition
becomes false, then it will exit from the loop. Just remember to initialize
only for one time. And the process
will do all things. Considered an example, that XOR five numbers and checks whether the number
is even or odd. If the number is even, display the message
the number is even. Otherwise, display the
message the number is odd. We have to accept five numbers
and check all the numbers, whether it is even
or odd in for loop. So first, we will begin our
pseudocode bit begin keyword. Then we will declare two
variables with numeric datatype. And then we will use for loop. We will take first number 0. It will be five numbers
from 0 to four. Our first condition in for
loop is n z t is equal to 0, which is initialize
this next question and 0 will get
stored in and CTR. Our second condition
is test expression. It will check whether NCT
r is less than equal to s4 is less than, less than equal to four. This condition is true
because in NCT our variable, we have 00 is less than four. So this condition is true. It will enter into the body
of the loop to begin keyword. And it will oxidate to enter
ox user to enter a number. Suppose user has entered ten. Then it will store that number in one variable through
except keyword. Then it will check if condition. Then it will check. If condition whether
the remainder of division is equal to 0 on this sign is
called modulus sign. It divides two numbers and
returns the remainder. So the condition
will become true and it will display
the number is even. Add here, our first
iteration ends. After first iteration. We will go on and CTR is
equal to NCT r plus one. It will add one to NCD, as you can see here. Now, it will again check
the test expression. Whether NCD r is less than
or equal to four or not. If it is equal to four, then the loop will terminate. If it is less than four, then it will enter into
the body of the loop. But after doing calculation, the value of n cdr will be one. As you can see here, the
value of NCD r is one. Then it will go, the condition becomes true. Then it will go in
the body of the loop. And then it will
display the number. Suppose we have entered 12. Now that 12 will be
accepted in num one. And then we'll divide 12 v2, we will get remainder 0. This condition also becomes
true because we have to find the remainder of 12. Idea. We are checking the remainder of 12th
in if condition. And this condition
becomes true and it will display the
number is even. Then again, it will
go to NCD, our NCT. It will add to another one, sorry, it will add one. Now the value of
entity or is one, then it will add one to it. Then the value of
entity or becomes two. Then it will check condition whether it is less
than four unknown. Yes, two is less than four. It will display number. Now suppose now we
will enter seven. So seven will be
accepted in num one. And when we divide seven by two, we will not get remainder 0. That means this
condition becomes false. It will go in as block and it will display
the number is odd. Then after the loop ends, it will add one more to it means now the value
of entity r is two. It will become three
after adding one to it. As you can see you,
they will check condition whether it is
less than four or not, the condition becomes true
and it will display number. Number will be
accepted in num one means that is stored in num one. Now we are taking
six even number. Then we will divide it by two. We will get remainder 0. It will display the
number is even. Then it will go to another loop. Then it will again go to MTTR
and it will add one to it. Now the value of
entity or becomes one, it will become four. So it will check whether NCT r is less than or equal to
four is not less than four, but it is equal to four. So again, accept a
number which is nine. We will divide but two, the result will be false, so it will display
the number is odd. Now idea of flowchart
means our pseudocode is finished because we
have achieved our tax. That is, we have to check whether we have to take five numbers and
check whether it is, it can be divided by two or not. This remainder is true or not. Then after finishing our
iteration for five times, it will exit from the loop. Because now the value
of MTTR becomes five, which is not less than four. So it will end the loop. Let's see what is while loop. The while loop
executes as long as the conditions specified
with the while loop is true. The moment the condition
becomes false, the loop breaks. The while loop
construct can be used for both fixed and
variable loop. This is an iterative
construct with our text expression at the top of the iterative statements. Iterative statements. This is syntax of
the while loop. It is in pseudocode. So fast
it will check condition, then it will exit the
body of the loop. What happened in fall loop? It will check first. First it will
initialize expression, then it will test the
condition that it will. And then it will
test the condition. If the condition becomes true and it will enter the
body of the loop. But in while loop, the
condition becomes true. It will enter the
body of the loop. Let's see an example of a while loop where we have to write a pseudocode to
display the average score of 30 students in a school. So for this, we will
declare four variables. With number, with sorry, with numeric datatype,
we will initialize N, max and total
encounter an average that is ABG with 0
and one respectively. Then we will check
the condition whether in but then counter is
less than two or not. Condition becomes
true. Then after we have initialized
encounter with 0, sorry with one, this
condition will become true. I need to enter in
the body of the loop. Then it will ask
the user to enter the total marks of the students. The max of students
will get stolen and Max through except keyword, then the total will be calculated and it will get
stolen and totally variable. Our first loop ends. It isn't continuous process. So we will add an
encounter with one. Now, the value of
encounter is one. Sorry. We will add an
encounter with one down. The value of encounter
becomes too, because first we have
initialized it to one. So one plus one, it becomes too. Now the second loop
has been started. It will again check
condition and it will run 30 times like this. It will run 30 times,
it will check. Again. It will check in
while condition, will ask the user to
enter. Like this. It will check what
for d times one, the condition becomes false, means the value of
encounter becomes 31. It will calculate average. It will divide
encounter with value to a t with whatever
will be the total. After getting the result, it will display the average
marks of the class. Whatever will be the
average level is lowered over will
be the average. It's flowchart. As you can see. We have started flowchart with start symbol
than you have taken. Four variables. Counter total average marks. Then initialize counter with one total average and max
initialized with zeros. And we check condition
in while loop. Whether is encountered
is less than the curator ds will
display the number, then N total is equal to
add marks to the total. Add one. To encounter. It will become two. We
check for 30 times. The loop will continue
for 30 times after the. So, after being the encounter, the value of encounter being 31, the loop will check condition
and it will become false. So it will calculate
the average. And it will display the
average of 30 miles. 30 seconds. Let's see what
is repeat until loop. The repeat until
loop differs from the wild loop only in the way
the condition is evaluated. In the while loop. The condition is evaluated
for tested before the body of the loop begins. Only if the condition is true, the control moves to
the body of the loop. In the repeat until loop. The body of the loop
is executed once, regardless of the condition
being true or false. And then the condition
is evaluated. The loop is executed. If the condition is false, the moment condition
becomes true. Loop breaks. Syntax of repeat until loop. Repeat keyword
will be used idea. Then it will check
condition in until keyword at the end of the loop. Consider an example that calculates the sum
of two numbers entered by the user. So we will start with
the go-to music in keyword, sorry, begin keyword. Then we will declare
four variables with numeric datatype. And we will assign value 0
to it to all four of them. We will use repeat keyword to start our repeat until loop. Then we will ask the user
to enter the first number. Then the number will
get stored in num one. Then we will ask
for second number, then that will be get
stored in num two. And the result will
get stored in. And some display keyword
will display the endosome. And then we will add
one to and counter. And it will repeat
the loop till, until, until n counter
becomes ten ones. Then counter variable
becomes greater than ten. That is 11. Then the loop will break. The loop will break because
we have calculated the sum of two numbers entered by enter
ten times by the user. Now I'm giving you two
cushions for practice. If you didn't understand
anything in this session or if you are not able to solve any questions or if
you have any doubt, then please don't hesitate to.