 Dear learner, I am Tapasheka Sabdas from the Department of Computer Science, Kisna Kanta Handik State of University. Today, I am going to discuss a topic, algorithm and flow set, which is from the course, Computer Programming using C. We have already heard about various programming languages like C, C++, Java, etc. A computer program is written in some programming language with the help of some instructions written in correct order to get a desired result. And the method of writing the instruction to solve the given problem is called programming. In order to write computer programs without any logical errors, it is recommended programmers to prepare a simple writing showing the steps involved in the program. With these discussions, the learners will be able to learn about algorithm, pseudocode and flow set. They will be able to define what is algorithm, what is pseudocode and what is a flow set. They will be able to write algorithms for various problems. They will also learn and use the various symbols of flow set. They will be able to draw different flow sets for different problems. Now what is an algorithm? An algorithm represents the step-by-step sequence of instructions required to solve a problem. In simple term, we can say an algorithm is a set of rules to get the expected output from a given input. An algorithm gives the logic of the program. An algorithm has a finite number of steps and some steps may involve some decision making and repetition. It is basically a blueprint to write a program to solve a particular problem. Now let me discuss the methods for writing an algorithm. For writing an algorithm, we have to first state the problem. That means first we are to state the problem we are trying to solve in clear and conscious terms. Next, we have to list the inputs. That means we are to list the inputs needed to solve the problem. After that we have to list the outputs. That means we are to find what the algorithm will produce as a result. Then we have to identify the steps. It is basically the steps which are needed to convert the process of inputs to produce the output. And the last step is to test the algorithm. That means we have to choose defined datasets and verify that our algorithm works for those datasets. There are certain terms which are used to develop an algorithm. We can use read, input and accept this type of words to represent input operation to give values of variables to a computer. Similarly, words like display, so, write or print can be used to represent the output operations. And forward arrow or the assignment symbol can be used to assign the result obtained by evaluating right side variables or expression to the left side variable. For branching and conditional statement we can use if then or if then else like phrases. The conditional statement usually contains some relational operators like less than, greater than, less than equal to or greater than equal to etc. These symbols are used while we shake some conditions in a branching or conditional statement. And for repetitive tasks like if we want to repeat certain tasks in a problem then we can use repeat for or repeat while phrases in an algorithm. Now let me discuss the types of statements in an algorithm. The statements in an algorithm are normally of 3 different types. One is sequential statements, then the other is selection or decision making statements then the iteration. Sequential statements are steps of the algorithm which is executed one by one sequentially in the specified order. The next one, selection or decision statements are used when the outcome of the process depends on some condition. And the general form for selection and decision making statements are first we have to give the if keyword then condition then we have to use the then keyword then statement one if the condition is true then only the statement one will be executed and if the condition is false that means the statement two will be executed from the else part. Now for repetition of works that means iteration we have to use the iterative or repetitive statements for this we can use repeat for or repeat while construct. Repetition occurs in one or more steps until some condition is true. Now let me come to the flow chart. What is a flow chart? A flow chart is basically a diagram, it is a graphical representation of sequence of steps to solve a problem. By looking at the flow chart one can understand the operations and sequence of operations performed in a system. That means by looking at the flow chart we can easily understand what will be the input, what will be the processing and what will be the output. To draw a flow chart certain symbols are used and those symbols are oval, oval is used for representing start and end of a flow chart. When we start to draw a particular flow chart of a program then we have to start with an oval, it is for starting and ending. The symbol parallelogram is used for input and output. In a program we have some input from the keyword then we have to use this parallel parallelogram symbol and similarly for output also this parallelogram symbol is used. Now a rectangular symbol is used for processing. Any kind of calculation can be done with the help of the use of this rectangular symbol and the diamond. This diamond symbol is used for giving some condition that means decision making and there are four arrows upward, downward, left and right arrows and these arrows represent the full flow line. That means these are used to include the flow of the logic by connecting symbols. Then a circle, a small circle is used to connect defined parts of a flow chart. Then in a big program the flow chart will be large so there may be required two pages. So to connect the symbols between two defined pages we can use this circle symbol and these are the symbols used for drawing a flow chart. Now let me discuss some simple program to write the algorithm and flow chart. Now this is a simple program to find the sum of two numbers and this is the steps for the algorithm. There are only four steps in this simple program. First step is to take the input as a and b. a and b are two variables and these are taken in step one. Then step two, sum is calculated a plus b that means the value of the variable a and the value of the variable is added and it is stored in the variable sum. It is a processing or calculation type of statement. Third step is display sum. It is a simple statement as the result of these two variables are stored in this variable sum so it is displayed. Then in the step four we have written stop that means the algorithm is finished. And this is the flow chart for the algorithm. First start symbol is denoted with the help of an open. Then input output is taken in a parallelogram. Then sum is calculated in a rectangular shape box. Then again the result that means the result is stored in this variable sum so it is in a parallelogram symbol. Then stop. This is the simple flow chart for this simple program. This is another example which is used to convert temperature from Celsius to Fahrenheit using the formula F equal to 9 by 5 into Celsius plus 32. This is the formula for converting temperature from Celsius to Fahrenheit. You have to know the formula that means you have to know the logic of the program. And this is the simple algorithm only four steps are used. In the step one temperature in Celsius is entered. In step two the calculation is done F equal to 9 by 5 into temperature in Celsius plus 32. This is the formula for converting temperature from Celsius to Fahrenheit. Then in step three display temperature in Fahrenheit. Then stop. This is the complete algorithm for this program. And the flow chart is shown here input is taken in variable C then calculation is done. Then temperature in Fahrenheit is displayed. This is the second example. In the third example one condition is here and this program is to find the algorithm and flow chart of a particular number which is even or odd. That means to check whether a number is even or odd. First we have to enter the number and it is stored in this variable n. Then one if then else is written. If number is divisible by 2 then the number is even. If the number is not divisible by 2 then the number is odd this is the condition. If the remainder is 0 that means n modulus operator 2 is equal to 0 that means there is no remainder that means the number is even else otherwise the number is odd. And this is the complete algorithm for this program. And in this flow chart we can see one diamond is used to input the condition first the number is taken in this variable n then it is said whether the number is divisible by 2 or not. If remainder is 0 that means the number is divisible by 2 yes that means the condition is true then the control will come to the even next part that means yes part it will give even number. If the number is not divisible by 2 it will go to the right hand side that means here the no part is written in the right hand side and it will display the odd number. And this is the flow chart for this type of problem where condition is used. This is another example in this example algorithm and flow chart to find the smallest of two numbers is shown. Where two numbers is taken as input then the two numbers is compared with the help of if then else statement if the number is small then it will display smallest number if the number is greater it will display the greater number. And the condition is tested in the flow chart with the help of a diamond shape symbol. In this example one algorithm is written and the flow chart is given to find the sum of first and assigned numbers that means n is entered through the keyboard suppose n is 5 then it will continue from 1 to 5 and it will calculate the sum of 1 to 5. Here one repetitive statement is used so repeat while is used here. In step 2 count is a variable and sum is a variable which is initialized to 0. Then in step 3 number is entered which can be any number like 5, 10, 50 etc. In step 4 it is written repeat step 4 and step 5 while count less than equal to n that means the loop will continue that means the repetition will continue until n becomes the counter becomes n. Initially count is initialized to 0 and when it becomes suppose I have entered 5 then it will the counter will become 5 at the n. And it will calculate the sum equal to sum plus n that means number is added with the variable sum and it will calculate the summation of all the numbers from 1 to n and in step 5 counter is incremented by 1 that means initially count is 1 for the next iteration that means for the next repetition the counter will become 1 initially 0 next 1 next 2 next 3 like this up to the number. Like this the total will be calculated and it will be stored in this variable sum. After that in the step 6 sum will be displayed with the help of a display statement. We can use display also here only I have used print word we can use any kind of word like print display write etc. And this is the flow chart for this algorithm. We have already discussed various examples of writing algorithm and flow chart of various simple programs. Now I am coming to what is pseudo code pseudo codes are informal language that helps programmers to develop algorithms. Studio code is very similar to everyday English language. It facilitates designers to focus on the logic of the algorithm without concentrating on the details of the language syntax. The sole purpose of pseudo codes is to enhance human understandability of the solution. Now let me discuss one example of pseudo code. This is the pseudo code to find the area of a rectangle. These are written in some informal language. First line is read height of the rectangle that means we have to enter the height of the rectangle then read width of the rectangle. We have to give the input of width of the rectangle then compute area as height into width. Because to find the area of a rectangle we have to multiply height and width. So first rectangular height and width are entered then it is calculated by height into width. This is the simple pseudo code for calculating the area of a rectangle. Now let me discuss another example. Write pseudo code and algorithm to determine a student's final grade and indicate whether it is passing or failing based on average mark greater than equal to 40. The final grade is calculated as the average of 5 subject marks. If the average marks of 5 subject is greater than or equal to 40 then the student will pass. Otherwise the student will fail. And we have to write the pseudo code for this problem. And this is the pseudo code for this example. First input a set of 5 subject marks then calculate their average by summing and dividing by 5. Then if average is below 40 and this is the condition then this will fail. Otherwise this will pass. If the average marks is more than 40 or equal to 40 he or she will pass. Otherwise she or she will be failed. And this is the detailed algorithm for this program. In step 1 first numbers of that means marks of 5 subjects are entered. In step 2 grade is calculated by summing up the marks and then dividing it by number 5 that means there are 5 subjects. So I have divided by 5. Then if the grade is less than or equal to 40 then the student will pass or fail. That means if the grade is less than 40 the student will fail or if the grade is greater than 40 then the student will pass. And this is the complete algorithm for this type of problem. Here I am showing the flow chart for this example. Here in the input part it is shown in a parallel algorithm. Marks of 5 subjects are taken. Then it is in a rectangular grade is calculated. Then one condition is given in a rhombus type symbol. If the grade is less than equal to 40 less than 40 then it here he or she will fail. If the grade is greater than equal to 40 then the student will pass. And this is the flow chart for this type of problem.