• 2 days ago
Transcript
00:00Hello everyone today I am going to explain lube within lube
00:05In my last video I have explained lube within lube with the example of a realistic approach
00:13I have given the realistic approach example to explain it
00:17I have given the example of a watch
00:20I have given the example of a clock
00:22How the hours, minutes and hand work
00:26How the time changes and the control comes to the minutes hand and the minutes hand take the full
00:31rotation from 1 to 60 and again controls goes back to the hours hand and it and the time changes
00:39and then again controls come back to the minutes hand
00:43So the hours hand is working as a outer loop and the minutes hand is working as a
00:48inner loop that I have explained in my last video
00:52So just keep the procedures that the method in which the clock works in your mind
00:58because the same methodology almost the same method of working of a clock
01:05is applicable in lube within lube also
01:07Okay so this is the program which I am going to explain of lube within lube
01:13What I have to display I have to display this one on the first row
01:18Then the second row I have to display one and two
01:21So on the second row it's going to cover the second row first column
01:27Then the second row second column and the third row I have to display one two three
01:32So it's going to cover what third row first column third row second column third row third column
01:42Okay so in this way I have to display first one
01:46and then one two then what one two three
01:49So here is a block diagram here's a flow chart of it
01:54This one where I am rotating my mouse i equals to one and i less than equals to three
02:00represents to the outer loop okay
02:03and the inner one where j equals to one and j less than equals to i
02:07this one represents to the inner loop okay
02:11So the outer loop is for the rows and the inner loop is for columns okay
02:18So let us do the dry run and understand how the things will work
02:22The value of i is what one one less than three the condition is true
02:28Just remember the values of i and j okay
02:32What is the value of i it's one one less than three the condition is true
02:37Immediately it will come inside the inner loop
02:40What is the value of j it's one okay j less than equals to i
02:46So what is the value of j it's one what is the value of i it's one
02:51So one equal to one the condition is true so I am going to display the value of j okay
02:57So I am going to display the value of j so what is the value of j it's one
03:01So one is going to display okay
03:05Now the value of j is going to change one plus one that is what two
03:11Now the new value of j is what two okay now the inner loop will continue
03:17The value of j is two two less than one as the value of i is one
03:24Here the condition will get false okay here the condition will get false
03:28It will come to the no part and it will come to the outer loop
03:32And the outer loop the value of i is going to increment
03:36What is the value of i it is one one is going to add with it
03:40So what one plus one that is what two okay
03:45Now the outer loop will work here it will go to the decision part
03:51Two less than three yes two is less than three the condition is true
03:56Immediately it will come to the inner loop
03:58Now as I've explained the example of clock and watch that when from hours hand control
04:07Comes to the minutes hand it's not going to start from 61 62 like that the minutes okay
04:13But it's going to start from its initial value that is one one minute
04:17And it will take the full rotation one two three four up to 60 minutes
04:22Then the hours hand will change the time
04:25The same procedure is applicable here once the control will come inside the inner loop
04:31The j is going to start from its initial value that is one okay
04:36So one less than equals to two this time value of i is what two yes one less than equals to two
04:43The condition is true it will come to the yes part
04:46What is the value of j it's one so one is going to print okay
04:51Then one plus one now the value of j is going to change that is what two okay
04:58Now the new value of j is what two inner loop will continue two equals to two
05:04Yes as the value of i is two we have to remember the values of the variables
05:10Value of j is two the value of i is two two equals to two the condition is true
05:15It will come to the yes part now it's going to display j
05:19And the value of j is what two so it's going to display what two okay
05:27Now two plus one that is what three two plus one three now the new value of j is three
05:34It will go here three less than two what will happen the condition will get false
05:40It will come to the no part
05:42To the outer loop the value of i is going to increment okay two plus one that is what three
05:51Now the value of i is incremented okay two plus one that is what three
05:56Now the new value of i is what three on the outer loop here three equals to three
06:03The condition is true now it will come to the inner loop
06:07The inner loop will start from its initial value that is j equals to one
06:12Now j is what one and it's going to compare with three one less than three
06:18Yes the condition is true the value of j is going to print that is what one
06:25Okay then the value of j is going to increment one plus one that is what two
06:30Okay now value of j is two okay two less than equals to what is the value of i it is
06:41Three so two less than three the condition is true it will come to the yes part what
06:47is the value of j this time it's two so two is going to print okay remember the values
06:53Now the incrementation will take place two plus one what three now the value of j is what three
06:59It will again go to this decision part three equal to three yes as the value of i is three
07:05So three equals to three the condition is true it will come to the yes part
07:09j is going to print so what is the value of j it's three so three is going to print okay
07:15Now three plus one that is what four three plus one that is what four now the new value of j is
07:21what four again it will come to the decision part four less than what is the value of i
07:27It's three four less than three condition will get false it will come to the no part
07:32Come here to the outer loop the value of i is going to increment from three it's going to
07:38add with one three plus one that is what four now the new value of i is what four okay it will come
07:44to the decision part four less than three four less than three the condition get false it will
07:51come to the no part and then stop but as the program says to display one then one two one
07:57two three we got the result okay so please watch this flowchart again and again to understand the
08:05concept I hope you must have understand it in the next video I'm going to make the program
08:13in C okay thanks for watching

Recommended