[0:05]Today we are discussing flowcharts. So what is a flowchart? First of all, let us define a flowchart. A flowchart is a diagrammatic representation of a process.
[0:16]Okay. In programming, it helps us in maintaining the proper sequence of instructions. So first of all, let us see what is a program.
[0:25]A program is a set of instructions in a proper sequence. Okay, so sequencing is very important in program and for maintaining the sequence, before writing the program, what we do, we draw a flowchart.
[0:39]Flowchart helps us in maintaining the sequence of a program. Okay.
[0:44]Whenever we start drawing a flowchart, we write start and then we enclose start.
[0:56]Okay, to this type of box, which is rounded from both the ends. See whenever we complete our flowchart, we write stop.
[1:07]Again we draw same type of box which is rounded from, okay, here and here. See whenever user supplies some values to the program, which is called input, inputting the values, okay?
[1:26]So what we do, we write input, or we write read, and then we write list of arguments. Suppose I am writing N1, N2, N3. It means whenever this program will get executed, at that time, user will supply you three values.
[1:48]Okay, first value will replace N1, second value will replace N2, and third value will replace N3. Okay.
[1:57]Similarly, whenever we want to display something to outside world, whenever the programmer wants to display something, some result to outside world, then what, what he will be doing? He will be writing print and again list of arguments, whose values you want to display.
[2:20]Okay, suppose arguments are A1, A2, A3, so I will be writing A1, A2, A3. So whenever this program will get executed, values of A1, A2, and A3 will be printed or will be displayed. Okay.
[2:40]Similarly, when we have to do some calculation, then we draw assignment box. Okay, which is a rectangular box. So this is, this type of rectangular box is called assignment box.
[3:03]Suppose I am writing result is equal to A into B plus C. So what will happen? First of all, this A into B plus C will be calculated.
[3:22]So, this will be calculated and this will be assigned to result. Okay. Now, suppose we have to take a decision.
[3:36]Suppose we are moving in this direction and now we have to take a decision, okay, logical decision, then we'll be drawing a decision box like this. Okay.
[3:51]Suppose, this is a logical decision, it means a yes, no type of decision. Is A greater than B?
[4:00]Okay. If it is yes, then I am moving in this direction and if it is no, then I am moving in this direction because either A will be greater than B or it will be smaller than or equal to B. So this is called a decision box.
[4:21]At times you require some connectors also. Okay. Suppose, suppose now I don't have space here.
[4:30]So now what will I be doing? I will be drawing a connector here. Suppose I draw connector, it's a circle. I draw connector here and I write X here.
[4:41]It means now I will be starting from, I will be resuming from X. So now if I write X and like this, it means whatever I have left here, now I am resuming from here. So this is called a connector.
[5:01]Okay. So, so far we are discussing only these many symbols because so far we won't be drawing loops. Whenever we draw loops then we'll be we will be discussing some more symbols. Okay.
[5:13]So now let us start drawing some basic flowcharts. See, our first problem is like this. Problem number one: Bhogilal sells mangoes at rupees 10 per mango.
[5:21]Mohan bought five mangoes from Bhogilal. Now we have to draw a flowchart to generate bill. Okay. Now here we know what is the rate. Rate is rupees 10 per mango. How many mangoes? Mohan bought five mangoes. Okay.
[5:41]So we'll be drawing flowchart like this. Now we need not to input anything because we already know everything. We know the rate, we know the number of mangoes.
[5:50]So we need not to input anything, we'll be drawing a flowchart like this. Start, we can directly calculate bill.
[6:05]We may write bill is equal to rate is 10 into number of mangoes is five.
[6:17]And after that, once we know the bill, then we'll be printing the value of bill. So we'll be drawing a parallelogram and we'll be writing print bill.
[6:33]Okay. And after that, I'm writing stop. So whenever a programmer will make a program according to this flowchart, okay, that program will not input anything.
[6:51]Whenever that program will get executed, it will be directly generating the value of bill and which will always be rupees 50. Okay.
[7:03]So normally our flowcharts are not as simple as this one. So let us take one more example. Next one.
[7:12]Now, let us discuss a bit more generalized type of problem. Problem number two: Bhogilal sells mangoes at rupees 10 per mango.
[7:22]Okay, so rate is fixed. Draw a flowchart to generate bill. Now, if we have to generate bill, we must know how many mangoes a customer is buying. So that is not given.
[7:35]It means that will be inputted in our program. Okay, that will be asked from the user. Whenever this program will get executed, that value will be supplied by the user.
[7:45]Okay, so now we have a flexibility. Earlier we were selling only five mangoes. Now we may change number of mangoes because the user will decide how many mangoes he has to buy.
[7:56]So now we'll be drawing our flowchart like this. We'll write start.
[8:08]Now we are not deciding number of mangoes. Number of mangoes will be supplied by the user, so we'll be writing input. Input means user will supply input number of mangoes. Okay, here we may write NM means number of mangoes.
[8:30]So, input number of mangoes, and after that we are writing, once we know number of mangoes, because rate is fixed, so what will be our bill?
[8:43]Our bill will be equal to 10. That is the rate and into number of mangoes.
[8:58]What do we do after this? After this, since we have calculated bill, so we have to display it to the outside world. So we'll be using a print statement. So what we'll have, we'll be enclosing it in a parallelogram and then we'll write print. I'll write print bill.
[9:27]So whenever this program will get executed, okay, because we are drawing flowchart, then based on this flowchart, what will happen? Programmer will write program and whenever this program will get executed at that time, what will happen? Okay, whenever programmer writes a program according to this flowchart, and that program gets executed, so at the execution time, first of all, here, the program will ask input number of mangoes.
[9:56]So the user will have to supply number of mangoes. Okay, then the program will calculate. And then the program will display. Okay, print or display bill. Okay, whatever bill we have calculated, that will be displayed to outside world. Okay, that's how this flowchart will work. Now let us take our problem number three which is more generalized.
[10:19]Here Bhogilal is selling mangoes. Okay, because rate may change every day, so rate is not given. Draw a flowchart to generate bill.
[10:29]So here rate is not given and number of mangoes because number of mangoes will also change from customer to customer. So that is also not given.
[10:40]So from where will we get rate and number of mangoes? So both have to be inputted. Okay, have to be, whenever we have to generate bill, so both these values have to be inputted, have to be supplied by the user. Okay.
[10:53]So our flowchart will be like this. Start.
[11:06]Now I'll have to input. Input first of all, number of mangoes and rate. Okay.
[11:28]We may specify what is NM, NM is number of mangoes.
[11:39]Once we know number of mangoes and rate then we can very well find bill. What will be our bill? Bill will be equal to number of mangoes into rate. Okay, basically it's rate per mango.
[12:00]So once we know number of mangoes and rate of, rate per mango, then we can always calculate bill is equal to number of mangoes into rate.
[12:13]Okay. And after that, what we do? Once we know the bill, then what we can do? We can display it. Print bill. Okay. Print average. Okay.
[12:41]So, now what happens? Whenever somebody writes a program according to this flowchart, this is small, whenever somebody writes a program according to this flowchart, then, and see once a program is written, so first of all it is compiled, it means it is changed, it is translated to machine language.
[13:00]Okay, and after that it's loaded and after that's you may execute it. So whenever this program will get executed, so first of all at this point, see user need to supply two values. Okay, the program will ask user to supply two values at this point.
[13:23]Number of mangoes and rate per mango. Okay. Based on these two values, a bill will be calculated. And once bill is calculated, the value of bill will be printed here. Okay. So now if some user is executing this program, so he need to supply two values.
[13:41]First is number of mangoes, second is rate. And soon after supplying these two values, he'll get a value which will be the value of bill. Okay. So this is our problem number, Bhogilal problem number three. Now we are just, okay, for, for some time we are shifting from Bhogilal.
[14:00]Okay. We are taking one more very simple flowchart. Draw a flowchart to find average of three numbers. Okay. So now this has to be a generalized program which should be able to find average of any three numbers. Okay.
[14:17]Now the question arises who will be supplying those numbers? The user will supply three numbers, okay, for which he wants to find average. So since the user has to supply three numbers, so our flowchart will be like this. We'll write start.
[14:38]And after this, because numbers have to be supplied by the user, so I'll have to input those numbers. Input means numbers will be supplied by the user. Input, suppose, okay, I am just taking three variables N1, N2 and N3.
[15:05]Okay. See, whenever this program will get executed, at that time three values will be supplied and first value will be replacing N1, second will be for N2 and third will be for N3. Okay. So once we have N1, N2 and N3, because in our program we are assuming that our three numbers are N1, N2 and N3. So what will be the sum?
[15:45]Sum will be N1, sorry N1 plus N2 plus N3. This is quite simple. Sum will be N1 plus N2 plus N3.
[16:02]And what will be average? Okay, I am taking a variable AVG for average. Average will be equal to sum divided by 3.
[16:15]And once we know the average, this will also be a rectangular box. I'm doing calculation. Once we know the average then what will we do? We will print average because we were supposed to calculate average. So what now what are we doing? We are displaying it. Print AVG.
[16:34]So whatever is the value of average that will be printed and then we stop. Okay.
[16:45]Now again same thing. Whenever this program will get executed at that time, first of all, the user has to supply three values. User has to supply three values N1, N2 and N3. Okay. Based on those three values, sum will be calculated. And after that average will be calculated and then average will be printed.
[17:10]Okay. Now I can draw a smaller flowchart also because these two things I can do in a single line also. So let, let me draw a smaller one. Start. Input N1, N2, N3.
[17:39]I can directly calculate average. AVG is equal to N1 plus N2 plus N3. This whole divided by 3. Okay. Since I am calculating, so this will be our rectangular box and after that I am writing print average. Okay.
[18:10]Print average and then I, just a minute. Print average and then I stop. Okay. Now what I have done, I have done these two things in a single line here. Okay, but I should not write like this. I should not write some of the students, they write like this. They write average is equal to N1 plus N2 plus N3 divided by 3.
[18:45]If they do like this, then only N3 will get divided by 3. Okay. Some of the students are doing it like this also, they write average is equal to N1 plus N2 plus N3 divided by 3. See this is not a computer statement because in computer, see whatever language, in whatever language you are doing programming, you have to write in a single line.
[19:12]So here first line, second line, third line. So this is not a valid computer statement. Okay. So your entire expression should be in continuity. So what is the right way of doing it? I have to write like this. Average is equal to N1 plus N2 plus N3. This whole divided by 3. Okay. So these two are wrong. Okay. Fine.



