1
00:00:01,280 --> 00:00:03,110
Hey, guys, what's up?

2
00:00:03,800 --> 00:00:07,880
So in this session, we will learn a new concept called Loop.

3
00:00:09,760 --> 00:00:14,020
So if you remember, we have done Leupen flowchart and pseudocode.

4
00:00:15,130 --> 00:00:15,380
OK.

5
00:00:15,760 --> 00:00:19,000
So this loop is exactly the same that we have done.

6
00:00:19,840 --> 00:00:24,490
So I am just we are doing a quick recap of how a loop work.

7
00:00:25,060 --> 00:00:28,920
So first of all, I was having an initialization first.

8
00:00:29,170 --> 00:00:30,180
We will initialize.

9
00:00:31,600 --> 00:00:33,700
Then I will have a condition.

10
00:00:35,900 --> 00:00:38,010
If this condition is true.

11
00:00:38,690 --> 00:00:42,830
So if this condition is true, then I will do some work.

12
00:00:44,270 --> 00:00:48,440
If this condition is true, I will do some work and then I will update.

13
00:00:51,090 --> 00:00:54,670
Then I will update and then after updating.

14
00:00:54,840 --> 00:00:59,700
I will check the condition again if the condition is again through.

15
00:01:00,030 --> 00:01:01,550
I will again do some work.

16
00:01:03,120 --> 00:01:10,120
And then I will update again, again, I will check the condition, but if condition is false.

17
00:01:10,290 --> 00:01:13,990
So if the condition is false, I will come out of the loop.

18
00:01:14,450 --> 00:01:17,100
So come out of the loop.

19
00:01:18,540 --> 00:01:21,960
So this is how a loop looks.

20
00:01:23,120 --> 00:01:24,710
OK, now let's see.

21
00:01:26,340 --> 00:01:34,080
So, for example, our task is to print hello five times.

22
00:01:35,580 --> 00:01:37,650
I want to print halloo five times.

23
00:01:37,920 --> 00:01:41,180
So what I can do is I can write Seo Tolu.

24
00:01:43,400 --> 00:01:45,170
And I will write it five times.

25
00:01:45,260 --> 00:01:45,880
So see out.

26
00:01:46,050 --> 00:01:46,430
Hello.

27
00:01:48,140 --> 00:01:48,760
So now.

28
00:01:49,310 --> 00:01:49,600
Hello.

29
00:01:49,680 --> 00:01:51,230
We printed five times.

30
00:01:51,590 --> 00:01:51,860
OK.

31
00:01:53,720 --> 00:01:56,340
I will just copy paste this line four more times.

32
00:01:57,440 --> 00:02:00,170
So in total, HelloWallet printer five times.

33
00:02:01,490 --> 00:02:05,360
But my task is to printed 500 times.

34
00:02:06,800 --> 00:02:07,840
So we have to right?

35
00:02:08,090 --> 00:02:11,980
We have to compete for 99 times to make it 500.

36
00:02:13,040 --> 00:02:14,080
Now I'm saying it.

37
00:02:14,180 --> 00:02:16,550
You have to print hello one million times.

38
00:02:18,530 --> 00:02:25,570
So obviously, by this time you might have noticed that this approach is very inefficient and time consuming.

39
00:02:26,630 --> 00:02:28,940
So what we can use, we can use a loop.

40
00:02:30,230 --> 00:02:31,190
So what will I do?

41
00:02:31,520 --> 00:02:35,510
I will say, hey, Lupe ran 500 times.

42
00:02:37,230 --> 00:02:42,290
Loop run 500 times, and each time this loop is running, I will bring telo.

43
00:02:44,480 --> 00:02:48,170
So this loop is running 500 times, and each time I am bending.

44
00:02:48,320 --> 00:02:48,800
Hello.

45
00:02:49,100 --> 00:02:49,550
So hello.

46
00:02:49,550 --> 00:02:51,680
Will be printed five hundred times.

47
00:02:54,150 --> 00:02:55,810
OK, so let's see.

48
00:02:57,350 --> 00:03:00,590
So if you remember in pseudocode, I was having.

49
00:03:01,650 --> 00:03:02,520
Via loop.

50
00:03:05,800 --> 00:03:08,150
So here we are also having while loop.

51
00:03:09,130 --> 00:03:12,460
So how does a code of why Loop looks like.

52
00:03:12,880 --> 00:03:14,350
So let's take a variable.

53
00:03:14,530 --> 00:03:15,990
I saw in time equals one.

54
00:03:16,150 --> 00:03:17,650
This is my initialization.

55
00:03:18,580 --> 00:03:21,290
While some condition will be there.

56
00:03:24,040 --> 00:03:26,260
And then some oblation will be.

57
00:03:28,560 --> 00:03:31,450
And here I will do my work that I want to do.

58
00:03:34,580 --> 00:03:35,300
So let's see.

59
00:03:36,050 --> 00:03:37,270
So let us spend hello.

60
00:03:37,420 --> 00:03:38,480
500 times.

61
00:03:40,680 --> 00:03:42,120
So I'm making a new file.

62
00:03:44,300 --> 00:03:45,870
Leard Snam, This Fire Les.

63
00:03:47,310 --> 00:03:47,940
While.

64
00:03:49,880 --> 00:03:51,330
Not CBB.

65
00:03:52,610 --> 00:03:52,930
OK.

66
00:04:23,550 --> 00:04:28,140
OK, so what we want to do is I want to print hello 500 times.

67
00:04:29,960 --> 00:04:34,610
So, OK, so let's first of all, print hello five times.

68
00:04:34,700 --> 00:04:36,170
So N.T. equals one.

69
00:04:37,700 --> 00:04:39,370
So this was my initialization.

70
00:04:39,410 --> 00:04:40,940
Now I will check the condition.

71
00:04:40,970 --> 00:04:43,890
So while vial is a key word here.

72
00:04:44,120 --> 00:04:44,390
OK.

73
00:04:44,780 --> 00:04:47,720
So while I lasdun articles two five.

74
00:04:50,430 --> 00:04:56,700
And I will update here a plus plus a plus plus means increment of a little five by one, it is same

75
00:04:56,700 --> 00:04:59,010
as I equals a plus one.

76
00:04:59,670 --> 00:05:02,820
Now each time this loop is learning, I have to print.

77
00:05:03,420 --> 00:05:03,810
Hello.

78
00:05:03,870 --> 00:05:04,560
So see you out.

79
00:05:06,150 --> 00:05:06,480
Hello.

80
00:05:11,110 --> 00:05:12,880
So this is all that we have to do.

81
00:05:13,570 --> 00:05:14,980
So let's put in our program.

82
00:05:17,370 --> 00:05:18,450
So we'll see out.

83
00:05:19,030 --> 00:05:20,610
Hello and Lane.

84
00:05:21,480 --> 00:05:22,300
So what is the error?

85
00:05:33,350 --> 00:05:34,150
OK, so.

86
00:05:35,830 --> 00:05:38,300
Analyze this.

87
00:05:39,170 --> 00:05:40,340
Now let us earn it again.

88
00:05:44,010 --> 00:05:47,100
So as you can see, Helo's printed five times.

89
00:05:47,820 --> 00:05:50,400
Now let's see how it is working.

90
00:05:52,290 --> 00:05:55,140
So first of all, this is my initialization.

91
00:05:56,100 --> 00:05:58,140
So this is initialization.

92
00:05:58,470 --> 00:05:59,670
First part of the loop.

93
00:06:02,250 --> 00:06:03,750
This is my condition.

94
00:06:03,780 --> 00:06:05,520
I list an order close to five.

95
00:06:05,730 --> 00:06:06,870
This is my condition.

96
00:06:08,100 --> 00:06:10,040
And this is my oblate.

97
00:06:12,420 --> 00:06:12,660
OK.

98
00:06:13,030 --> 00:06:15,790
So all three combatants of a loop are present.

99
00:06:16,830 --> 00:06:18,750
So how many times this little building.

100
00:06:19,440 --> 00:06:27,220
So initially I was when and in the condition I am checking while I left, then we're close to five.

101
00:06:28,080 --> 00:06:29,280
So this is my condition.

102
00:06:30,000 --> 00:06:34,110
And each time I am incrementing the value of I buy one.

103
00:06:34,890 --> 00:06:37,470
So this means I equals a plus one.

104
00:06:37,920 --> 00:06:39,870
This is just another way of writing.

105
00:06:40,020 --> 00:06:41,280
I quote I plus one.

106
00:06:42,070 --> 00:06:42,310
OK.

107
00:06:42,600 --> 00:06:44,490
So initially the value of fi is one.

108
00:06:44,730 --> 00:06:47,760
And each time I am incrementing the value if I buy one.

109
00:06:48,150 --> 00:06:50,430
And this low in this condition.

110
00:06:50,640 --> 00:06:54,150
So with the help of these three, my loop will run five times.

111
00:06:55,970 --> 00:06:56,230
OK.

112
00:06:58,080 --> 00:07:03,610
Initially, the value of fire is one each time the slope is running, I am incrementing the value of

113
00:07:03,610 --> 00:07:04,440
fire by one.

114
00:07:04,770 --> 00:07:07,500
And my condition is I list in order close to five.

115
00:07:07,620 --> 00:07:10,170
So in total, this loop will run five times.

116
00:07:10,500 --> 00:07:13,350
And each time this loop is running, I am printing.

117
00:07:13,500 --> 00:07:14,040
Hello.

118
00:07:14,880 --> 00:07:18,210
So in total, hello will be Brendel 500 times.

119
00:07:20,190 --> 00:07:26,440
OK, so what if I remove it close to a list in five?

120
00:07:26,560 --> 00:07:27,370
How many times?

121
00:07:27,430 --> 00:07:28,540
Now this loop will run.

122
00:07:29,320 --> 00:07:32,170
So this loop will run four times.

123
00:07:32,770 --> 00:07:33,280
Let's see.

124
00:07:36,570 --> 00:07:40,110
So Hillary is getting printed four times by.

125
00:07:47,030 --> 00:07:50,960
So when the value of AI is when this condition is true.

126
00:07:51,060 --> 00:07:51,950
Hello teleprinter.

127
00:07:52,070 --> 00:07:57,710
So when when I equals two to this condition will again do so.

128
00:07:57,740 --> 00:07:57,940
Hello.

129
00:07:57,950 --> 00:07:58,490
Blueprinted.

130
00:07:58,580 --> 00:08:01,460
Two times when I was three.

131
00:08:01,760 --> 00:08:03,620
This condition is again to trace.

132
00:08:03,770 --> 00:08:04,490
Less than five.

133
00:08:04,760 --> 00:08:05,230
So hello.

134
00:08:05,230 --> 00:08:06,200
Ilive rendered again.

135
00:08:06,290 --> 00:08:07,010
So three times.

136
00:08:07,010 --> 00:08:07,310
Hello.

137
00:08:07,760 --> 00:08:10,970
When I equals four four it is less than five.

138
00:08:11,030 --> 00:08:12,650
This condition is again true.

139
00:08:13,000 --> 00:08:14,630
Harrowingly brain dead one more time.

140
00:08:14,690 --> 00:08:15,650
So lower spending.

141
00:08:15,710 --> 00:08:19,370
Hello is getting rendered four times when I equals five.

142
00:08:19,460 --> 00:08:25,190
This condition will become false because five is not less than five.

143
00:08:25,460 --> 00:08:26,090
This is wrong.

144
00:08:26,540 --> 00:08:31,400
So this condition will become false and I will reach line number 14.

145
00:08:33,090 --> 00:08:35,860
OK, so hello, loop under four times.

146
00:08:39,760 --> 00:08:42,040
Now, let's take one more example.

147
00:08:44,350 --> 00:08:45,400
So suppose.

148
00:08:48,040 --> 00:08:51,540
Now, if I want to print hello 500 times.

149
00:08:52,000 --> 00:08:55,180
So the only change that I have to do, I will right here.

150
00:08:55,410 --> 00:08:58,060
500 or let's say five thousand.

151
00:08:58,200 --> 00:08:59,140
Fifty thousand.

152
00:09:00,270 --> 00:09:00,530
OK.

153
00:09:00,830 --> 00:09:03,250
So this is the benefit of the loop.

154
00:09:03,730 --> 00:09:05,080
This is the advantage of a loop.

155
00:09:05,920 --> 00:09:06,550
So listen.

156
00:09:09,410 --> 00:09:13,880
So as you can see, our program is running five thousand times.

157
00:09:18,100 --> 00:09:23,110
Now, let's see one more thing, how this halloo is getting printed.

158
00:09:23,260 --> 00:09:24,100
Five things.

159
00:09:27,500 --> 00:09:33,110
So my code is very simple and I equals one.

160
00:09:34,510 --> 00:09:43,040
While I is less than or equal to five, I am printing hello.

161
00:09:45,950 --> 00:09:49,570
And then I am incrementing to vilify my one.

162
00:09:51,530 --> 00:09:53,330
So let's say, hey, is my output.

163
00:09:57,920 --> 00:09:58,910
So this is my output.

164
00:09:59,510 --> 00:10:01,850
So initially the value of AI is one.

165
00:10:02,510 --> 00:10:04,700
OK, so AI is one.

166
00:10:05,440 --> 00:10:08,290
The condition is one less 10 articles to five.

167
00:10:09,700 --> 00:10:11,510
Is one less than or close to five?

168
00:10:11,570 --> 00:10:12,700
Yes, the condition is true.

169
00:10:12,940 --> 00:10:14,320
You will come inside the loop.

170
00:10:15,340 --> 00:10:15,960
You will print.

171
00:10:16,000 --> 00:10:16,300
Hello.

172
00:10:16,570 --> 00:10:17,770
So in my output.

173
00:10:17,950 --> 00:10:18,220
Hello.

174
00:10:18,220 --> 00:10:19,300
Is getting printed.

175
00:10:20,440 --> 00:10:22,700
Then you add incrementing the value if I buy one.

176
00:10:23,140 --> 00:10:28,600
So the new value if I will become to and from this broker to you will again reach here.

177
00:10:29,680 --> 00:10:34,360
Now you will check the condition again is to less than or equal to five.

178
00:10:34,700 --> 00:10:36,010
Yes, the condition is true.

179
00:10:36,220 --> 00:10:37,120
You will again print.

180
00:10:37,240 --> 00:10:37,990
Hello sir.

181
00:10:38,170 --> 00:10:38,590
Hello.

182
00:10:38,800 --> 00:10:39,970
Will be printed again.

183
00:10:40,600 --> 00:10:42,640
Now you will increase the value if I buy one.

184
00:10:42,670 --> 00:10:44,910
So a new value of fly is three.

185
00:10:45,640 --> 00:10:49,180
Now you will again check the condition.

186
00:10:49,780 --> 00:10:52,030
So is three list in order close to five.

187
00:10:52,120 --> 00:10:53,410
Yes, the condition is true.

188
00:10:53,680 --> 00:10:56,260
So will you will come inside and you will print.

189
00:10:56,590 --> 00:10:56,890
Hello.

190
00:10:57,270 --> 00:10:57,700
So hello.

191
00:10:57,700 --> 00:10:59,650
Is getting printed one more time.

192
00:11:00,130 --> 00:11:02,440
And now you will increase the value of I buy one.

193
00:11:02,470 --> 00:11:04,360
So the new value of five is No.

194
00:11:04,930 --> 00:11:05,280
Four.

195
00:11:05,930 --> 00:11:09,960
Now you will again reach here and you will check the condition again.

196
00:11:10,600 --> 00:11:13,960
So is for less than not close to five years.

197
00:11:14,110 --> 00:11:16,080
The condition is again true.

198
00:11:16,390 --> 00:11:17,800
You will print hello again.

199
00:11:18,150 --> 00:11:20,320
So hello will be printed again.

200
00:11:20,860 --> 00:11:25,630
Now you will increase the value of I by one to the new value of I will become forward.

201
00:11:26,020 --> 00:11:28,510
Now you will check the condition again.

202
00:11:29,140 --> 00:11:32,170
So is five less than articles to five.

203
00:11:32,470 --> 00:11:35,290
Yes, five is less than articles to five.

204
00:11:35,650 --> 00:11:37,150
So welcome Inside the Loop.

205
00:11:37,180 --> 00:11:37,960
And you will print.

206
00:11:38,010 --> 00:11:38,380
Hello.

207
00:11:38,800 --> 00:11:40,300
So hello is getting Brender.

208
00:11:40,390 --> 00:11:41,320
One more time.

209
00:11:41,680 --> 00:11:43,900
And then you will increase the value of I.

210
00:11:44,530 --> 00:11:45,050
So I.

211
00:11:45,070 --> 00:11:46,450
It was six.

212
00:11:46,870 --> 00:11:48,930
Now you will check the condition again.

213
00:11:49,210 --> 00:11:50,500
So is six.

214
00:11:50,520 --> 00:11:52,090
Less than Orchestre five.

215
00:11:52,240 --> 00:11:52,660
No.

216
00:11:53,020 --> 00:11:57,210
So this condition will become fallers when I.

217
00:11:57,240 --> 00:11:58,330
Becomes six.

218
00:11:58,990 --> 00:12:02,530
So since this condition is false, I will not go inside the loop.

219
00:12:03,220 --> 00:12:04,990
I will reach at this line.

220
00:12:06,280 --> 00:12:06,540
OK.

221
00:12:06,850 --> 00:12:08,020
And this is my output.

222
00:12:08,410 --> 00:12:08,680
Hello.

223
00:12:08,680 --> 00:12:11,340
Is getting printed five times.

224
00:12:12,520 --> 00:12:12,740
OK.

225
00:12:13,090 --> 00:12:15,010
So this is how a loop works.

226
00:12:15,730 --> 00:12:19,300
Now let me tell you the concept of infinite loop.

227
00:12:19,840 --> 00:12:20,030
OK.

228
00:12:20,080 --> 00:12:22,550
So what if I remove this update condition?

229
00:12:23,620 --> 00:12:26,260
What will happen if I remove the subject condition?

230
00:12:27,730 --> 00:12:28,420
So let's see.

231
00:12:32,910 --> 00:12:40,440
So you can see hello is getting printed in finite times, so this loop will never stop.

232
00:12:42,060 --> 00:12:43,680
This loop will never stop.

233
00:12:43,710 --> 00:12:45,210
It will keep on executing.

234
00:12:45,860 --> 00:12:49,440
So why this helo is getting printed infinite number of times.

235
00:12:50,480 --> 00:12:55,820
So let us try to understand why it is so OK, so this will not stop.

236
00:12:55,880 --> 00:12:57,920
You have to stop it from here.

237
00:12:59,430 --> 00:13:01,890
Now, let's see what is happening in.

238
00:13:08,630 --> 00:13:10,830
So our record is in question.

239
00:13:12,620 --> 00:13:20,160
While I is less than or equal to five, then you are printing hello here.

240
00:13:22,940 --> 00:13:28,140
And then we have commandeered this line I E-Plus plus.

241
00:13:29,150 --> 00:13:30,320
So let's see what happens.

242
00:13:31,160 --> 00:13:32,480
So here is my output.

243
00:13:34,850 --> 00:13:36,910
First of all, I will check my equation.

244
00:13:36,980 --> 00:13:37,210
OK.

245
00:13:37,280 --> 00:13:38,510
So I equals one.

246
00:13:38,840 --> 00:13:41,990
Now I will check every condition is one less than close to five.

247
00:13:42,050 --> 00:13:42,260
Yes.

248
00:13:42,260 --> 00:13:44,510
The condition is to go inside the loop.

249
00:13:44,570 --> 00:13:44,840
Brent.

250
00:13:44,840 --> 00:13:45,170
Hello.

251
00:13:46,280 --> 00:13:46,520
OK.

252
00:13:46,580 --> 00:13:47,270
I am printing.

253
00:13:47,300 --> 00:13:47,660
Hello.

254
00:13:47,930 --> 00:13:49,220
So this line is a comment.

255
00:13:49,370 --> 00:13:51,860
We will not do anything now from this record.

256
00:13:51,980 --> 00:13:53,390
I will check the condition again.

257
00:13:54,540 --> 00:13:56,290
So the value of AI is again one.

258
00:13:56,330 --> 00:13:57,950
So one is less than it goes to five.

259
00:13:58,010 --> 00:13:58,100
Yes.

260
00:13:58,100 --> 00:13:59,090
Have the condition is true.

261
00:13:59,640 --> 00:14:01,730
Brent, hello again.

262
00:14:02,630 --> 00:14:03,470
Condition is true.

263
00:14:03,860 --> 00:14:04,160
Brent.

264
00:14:04,160 --> 00:14:05,830
Hello again.

265
00:14:06,080 --> 00:14:06,980
The condition is true.

266
00:14:07,070 --> 00:14:07,370
Brent.

267
00:14:07,370 --> 00:14:08,560
Hello again.

268
00:14:08,570 --> 00:14:09,600
The condition is true.

269
00:14:09,710 --> 00:14:11,080
Brent, hello again.

270
00:14:11,090 --> 00:14:12,020
The condition is true.

271
00:14:12,110 --> 00:14:12,380
Brent.

272
00:14:12,380 --> 00:14:12,680
Hello.

273
00:14:13,040 --> 00:14:21,170
So I will always be one since I is always one and one and one is always less than close to five.

274
00:14:21,500 --> 00:14:23,780
So this condition is always true.

275
00:14:25,340 --> 00:14:26,230
True, always.

276
00:14:27,550 --> 00:14:29,960
So this condition is always true.

277
00:14:29,960 --> 00:14:30,940
And that is that is reason.

278
00:14:31,010 --> 00:14:31,380
Hello.

279
00:14:31,380 --> 00:14:31,600
Really.

280
00:14:32,090 --> 00:14:32,330
Hello.

281
00:14:32,340 --> 00:14:36,340
We keep bringing in finite number of times.

282
00:14:38,640 --> 00:14:43,530
OK, so that's that is there is an updated condition is important.

283
00:14:44,220 --> 00:14:50,740
So if you would an outright W8 condition or the right update condition wrong, our loop will run in

284
00:14:50,810 --> 00:14:52,210
finite number of times.

285
00:14:53,680 --> 00:14:54,970
OK, now let us.

286
00:14:55,050 --> 00:14:55,500
Right.

287
00:14:56,610 --> 00:14:57,360
Wrong loop.

288
00:14:58,970 --> 00:15:07,370
So instead of incrementing, I plus plus, what if I'm updating, but I am doing it wrong, I am decreasing

289
00:15:07,370 --> 00:15:13,280
the value if I buy one in this case also my loop will run and finite number of times.

290
00:15:13,370 --> 00:15:13,910
Let's see.

291
00:15:18,700 --> 00:15:26,500
So as you can see, again, this loop is an infinite loop, Hallowell get printed and finite number

292
00:15:26,500 --> 00:15:27,120
of times.

293
00:15:28,250 --> 00:15:30,770
Now, we have written W8 condition here.

294
00:15:30,860 --> 00:15:35,710
So why this loop is infinite running infinite number of times in the previous case?

295
00:15:36,050 --> 00:15:37,700
I commended W8 condition.

296
00:15:38,090 --> 00:15:40,610
So there it is, the reason my condition was always true.

297
00:15:41,730 --> 00:15:42,790
OK, Martin.

298
00:15:43,090 --> 00:15:48,910
We have an updated condition then also my loop is running in finite number of things.

299
00:15:49,480 --> 00:15:50,740
So what is happening here?

300
00:15:51,130 --> 00:15:52,380
Let's try to understand.

301
00:15:56,610 --> 00:16:03,330
So in previous case, Lupe was running in funny at times because we have commented out IWD condition.

302
00:16:03,750 --> 00:16:06,310
But in this case, we have written ablate condition.

303
00:16:06,360 --> 00:16:12,360
Then also my loop is running in finite number of times, socio telo.

304
00:16:14,730 --> 00:16:17,670
Now we are decreasing the value of fire by one.

305
00:16:19,350 --> 00:16:21,420
OK, so here's my output.

306
00:16:24,210 --> 00:16:25,170
I equals one.

307
00:16:25,470 --> 00:16:27,330
So is one less than close to five.

308
00:16:27,370 --> 00:16:28,530
Yes, the condition is true.

309
00:16:29,040 --> 00:16:29,580
Brent hello.

310
00:16:30,180 --> 00:16:30,930
So is he out?

311
00:16:31,470 --> 00:16:31,830
Hello.

312
00:16:32,370 --> 00:16:33,490
The keys, the radio five.

313
00:16:33,500 --> 00:16:35,910
I once knew a little five will become zero.

314
00:16:36,330 --> 00:16:40,560
Now check the condition again is zero listing close to five.

315
00:16:40,710 --> 00:16:41,100
Yes.

316
00:16:41,200 --> 00:16:43,620
Zero is less than out of close to five.

317
00:16:44,160 --> 00:16:46,510
So I will come inside the loop and I will print.

318
00:16:46,560 --> 00:16:47,340
Hello again.

319
00:16:48,510 --> 00:16:52,320
Now the keys to vilify by went to the new l'oeil five becomes minus one.

320
00:16:52,830 --> 00:16:54,760
And now you will check the condition again.

321
00:16:55,170 --> 00:16:56,970
So is minus one.

322
00:16:57,340 --> 00:16:58,770
Let's 10 articles to five.

323
00:16:58,800 --> 00:16:59,970
Yes, the condition is true.

324
00:17:00,240 --> 00:17:02,730
You will come inside the loop and you will print.

325
00:17:02,970 --> 00:17:03,990
Hello again.

326
00:17:04,830 --> 00:17:06,530
Now the keys to vilify by one.

327
00:17:06,570 --> 00:17:07,010
So new.

328
00:17:07,010 --> 00:17:11,150
Well, if I is minus two again you will check the condition head.

329
00:17:11,220 --> 00:17:12,450
Will we get printed.

330
00:17:12,820 --> 00:17:14,360
Now I equals minus three.

331
00:17:14,370 --> 00:17:15,270
Then minus four.

332
00:17:15,300 --> 00:17:15,960
And so on.

333
00:17:17,550 --> 00:17:17,800
OK.

334
00:17:18,170 --> 00:17:21,440
So basically, I will never become close to six.

335
00:17:23,910 --> 00:17:27,030
OK, so the value of FI is decreasing.

336
00:17:28,200 --> 00:17:29,550
And what should happen?

337
00:17:29,630 --> 00:17:31,380
The value of I should have increased.

338
00:17:32,970 --> 00:17:40,460
But in this case, the vilify is decreasing and hence the value of I will never become greater than

339
00:17:40,470 --> 00:17:44,110
five since the very five will never become good.

340
00:17:44,140 --> 00:17:44,760
Then five.

341
00:17:45,180 --> 00:17:48,210
This loop will always be true.

342
00:17:49,720 --> 00:17:53,170
This loop will always be true.

343
00:17:53,530 --> 00:17:57,700
And that is the reason hello will get printed in finite number of times.

344
00:17:58,870 --> 00:18:00,040
In previous case.

345
00:18:01,730 --> 00:18:08,950
In previous case, this condition was true because we have not returned the update statement.

346
00:18:11,080 --> 00:18:11,360
OK.

347
00:18:11,730 --> 00:18:14,100
In this case, I believe statement was missing.

348
00:18:14,250 --> 00:18:16,920
Notice the reason this condition was always true.

349
00:18:17,550 --> 00:18:21,650
But in this case, we have written the updated condition.

350
00:18:21,930 --> 00:18:24,810
But we have written the wrong update condition.

351
00:18:25,260 --> 00:18:28,950
So that is there is in this loop is always through.

352
00:18:30,580 --> 00:18:30,870
OK.

353
00:18:31,770 --> 00:18:35,670
Now, there is one more way to make our loop.

354
00:18:37,960 --> 00:18:38,670
Always true.

355
00:18:38,760 --> 00:18:39,600
So what we can do.

356
00:18:39,680 --> 00:18:39,980
OK.

357
00:18:40,080 --> 00:18:40,490
Sorry.

358
00:18:40,560 --> 00:18:41,100
See old.

359
00:18:45,710 --> 00:18:52,550
So basically, the main concept is my loop will run an infinite number of times only when my condition

360
00:18:52,550 --> 00:18:53,810
is always true.

361
00:18:54,740 --> 00:18:59,360
OK, so this is the mean idea of running a loop and in a number of games.

362
00:18:59,960 --> 00:19:00,670
What do you do?

363
00:19:01,070 --> 00:19:02,620
Make the loop always.

364
00:19:03,220 --> 00:19:06,260
So wild when one means through.

365
00:19:06,890 --> 00:19:11,150
So vilely means run the loop infinite number of times.

366
00:19:11,210 --> 00:19:14,280
So this loop will run infinite number of times.

367
00:19:14,480 --> 00:19:15,020
Let's see.

368
00:19:18,190 --> 00:19:24,540
So as you can see, this loop is also running in finite number of times.

369
00:19:26,740 --> 00:19:27,000
OK.

370
00:19:29,890 --> 00:19:32,770
Now, why this little boy is running and fired a number of times to.

371
00:19:32,890 --> 00:19:38,520
So the logic is very simple, Viall when I am printing hello.

372
00:19:43,000 --> 00:19:52,210
So if you look carefully at the above example, my loop will run in finite number of times if the condition

373
00:19:52,210 --> 00:19:53,350
is true, all these.

374
00:19:54,360 --> 00:20:02,430
Similarly, hair, my lube with was also running in finite a number of times because this condition

375
00:20:02,430 --> 00:20:03,600
was always true.

376
00:20:04,230 --> 00:20:12,630
So the main concept is any loop will run in finite number of times if the condition is always true.

377
00:20:13,080 --> 00:20:22,770
So if the condition is always through, my loop will run in finite number of times.

378
00:20:24,180 --> 00:20:31,560
So I have already told you on that any positive value, any positive value means through and the zero

379
00:20:31,560 --> 00:20:32,730
means false.

380
00:20:33,750 --> 00:20:36,910
So one means through survival, through.

381
00:20:37,200 --> 00:20:42,950
So this condition will always be true and will be printed in finite number of times.

382
00:20:44,300 --> 00:20:44,540
OK.

383
00:20:44,850 --> 00:20:47,160
So what will happen instead of writing one here?

384
00:20:47,190 --> 00:20:48,120
I write five.

385
00:20:48,660 --> 00:20:52,500
Then also this loop will end in fact number of times because five means through.

386
00:20:53,130 --> 00:20:55,830
Similarly, you can write three, seven, eight anyway.

387
00:20:56,760 --> 00:21:02,130
And if we write vilely, zero zero means Falls City out.

388
00:21:02,820 --> 00:21:03,210
Hello.

389
00:21:04,740 --> 00:21:08,430
So if you will run this, my loop will not run.

390
00:21:09,060 --> 00:21:13,920
So hello will not be Brender because this is false.

391
00:21:14,430 --> 00:21:16,890
Since the condition is false, I will reach here.

392
00:21:17,010 --> 00:21:18,930
I will not go inside the loop.

393
00:21:19,770 --> 00:21:20,390
So let's see.

394
00:21:21,950 --> 00:21:24,200
So Insitute of One here you can write anyway, Lou.

395
00:21:24,300 --> 00:21:25,460
For example, seven.

396
00:21:28,170 --> 00:21:31,140
Because seven is a positive number.

397
00:21:31,560 --> 00:21:34,040
Has the condition a lot less brutal.

398
00:21:34,080 --> 00:21:35,350
So the loop is running fine.

399
00:21:35,400 --> 00:21:36,210
Number of times.

400
00:21:37,110 --> 00:21:38,280
Now, let us slide here.

401
00:21:38,430 --> 00:21:38,820
Zero.

402
00:21:39,120 --> 00:21:45,000
So while zero zero means false, since the condition is false, I will not go inside the loop.

403
00:21:45,540 --> 00:21:47,980
I will directly commit line number one.

404
00:21:49,230 --> 00:21:50,730
OK, so I will likely come here.

405
00:21:50,840 --> 00:21:51,960
Line number two.

406
00:21:55,880 --> 00:21:56,120
OK.

407
00:21:56,760 --> 00:21:58,530
So nothing is getting printed.

408
00:21:59,160 --> 00:21:59,580
Great.

409
00:22:02,680 --> 00:22:05,850
Now, our task force, we have to print hello.

410
00:22:07,330 --> 00:22:08,380
We have to print hello.

411
00:22:10,470 --> 00:22:13,730
Let's say 2000 times our problem was started.

412
00:22:14,370 --> 00:22:17,190
So our problem was started from 5000 times.

413
00:22:17,310 --> 00:22:19,020
We have to print our low 5000 times.

414
00:22:19,770 --> 00:22:21,210
So logic is very simple.

415
00:22:21,810 --> 00:22:22,890
Take a video, Ballay.

416
00:22:24,770 --> 00:22:26,110
And you should either to one.

417
00:22:27,050 --> 00:22:27,260
Right.

418
00:22:27,290 --> 00:22:29,360
The condition condition is very simple.

419
00:22:29,480 --> 00:22:34,160
While a listing goes to five and just increment the radio five by one.

420
00:22:34,220 --> 00:22:35,240
So I bless plus.

421
00:22:36,260 --> 00:22:38,090
Now, this loop is perfect.

422
00:22:38,600 --> 00:22:39,850
So HelloWallet Carpenter.

423
00:22:40,000 --> 00:22:41,330
Five thousand times.

424
00:22:46,150 --> 00:22:47,480
So hello is getting Brender.

425
00:22:47,660 --> 00:22:50,120
Five thousand times you can scroll up if you want.

426
00:22:50,780 --> 00:22:53,450
And if you have extra time, you can also countered.

427
00:22:56,980 --> 00:22:57,190
OK.

428
00:22:57,630 --> 00:22:59,890
So this is the mean idea of a loop.

429
00:23:00,780 --> 00:23:02,750
No incoming weirdos from what we will do.

430
00:23:02,860 --> 00:23:09,200
We will solve many problems with the help of Loop to get a better understanding how the loop is working.

431
00:23:10,390 --> 00:23:12,610
OK, so that is all for this video.

432
00:23:12,910 --> 00:23:13,390
Thank you.
