1

00:00:01,020  -->  00:00:08,380
Not let's look at an authority that you can go for straight rent while statement or why loop a while

2

00:00:08,390  -->  00:00:11,190
loop like a for loop is an education statement.

3

00:00:12,530  -->  00:00:18,100
You should use follow up if you know how many times to look otherwise you should go for it while.

4

00:00:20,150  -->  00:00:24,430
Why Lopez only condition expression on here is a general form.

5

00:00:24,440  -->  00:00:29,900
As long as a condition expression is true the body of y look keeps getting executed.

6

00:00:29,990  -->  00:00:31,970
So there is no initialization part.

7

00:00:32,240  -->  00:00:40,120
Similarly there is not an expression to all that can be included in the body offwell There is also a

8

00:00:40,120  -->  00:00:46,930
variation of vyle statement called blue eyed statement you would use it if the body of Weil must run

9

00:00:46,990  -->  00:00:50,720
at least once and here is the syntax.

10

00:00:51,040  -->  00:00:57,250
As you can see the body of Weil is followed by the condition expression so the body gets executed at

11

00:00:57,250  -->  00:01:05,160
least once subsequently the body keeps getting executed on the commission expression is false not do

12

00:01:05,160  -->  00:01:13,010
one statement and with the semicolon Otherwise you get a compilation error here's a good example where

13

00:01:13,030  -->  00:01:14,460
Deuel is used.

14

00:01:14,960  -->  00:01:21,200
Let's if you want to write some simple logic to perform some action based on user's input if you separate

15

00:01:21,200  -->  00:01:22,590
what's a positive number.

16

00:01:22,610  -->  00:01:24,090
We perform the action.

17

00:01:24,410  -->  00:01:27,800
Otherwise the user is asked to re-enter that number.

18

00:01:28,040  -->  00:01:34,340
So we need to first collect the input from user and then check if the input is positive or not.

19

00:01:34,340  -->  00:01:37,490
This can be achieved using a do look as shown here.

20

00:01:37,910  -->  00:01:44,480
The user input collection is done in the body and the while condition checks if and don't input is positive

21

00:01:44,480  -->  00:01:50,970
or not so if they use it and there's zero or a negative number then the while condition would be true

22

00:01:51,300  -->  00:01:55,280
and the user will be prompted to re-enter that number.

23

00:01:55,290  -->  00:02:01,110
This can be use under the user enters a positive number at which time the while condition fails on the

24

00:02:01,110  -->  00:02:02,770
intended action is performed.

25

00:02:04,500  -->  00:02:08,790
Not let's look at in finite look which basically loops infinitely.

26

00:02:08,940  -->  00:02:10,300
That is it loops forever.

27

00:02:11,900  -->  00:02:19,620
For example let's consider a company which wants to send marketing e-mails every morning at Adium and

28

00:02:19,720  -->  00:02:25,600
this can be achieved using a while loop as shown here that is a condition expression would always be

29

00:02:25,600  -->  00:02:33,170
true and hence a body of the while loop keeps repeating forever but with each iteration a check is made

30

00:02:33,260  -->  00:02:35,880
if the current time is 8 a.m..

31

00:02:35,930  -->  00:02:40,990
If that's the case then emails are standard by invoking sending mother.

32

00:02:41,220  -->  00:02:48,000
Otherwise we continue to look this can also be you'll be using a frontal lobe as shown here.

33

00:02:48,930  -->  00:02:51,220
As you can see to simulate an infinite loop.

34

00:02:51,450  -->  00:02:55,020
The parenthesis does not include any of the expressions.

35

00:02:55,230  -->  00:03:02,190
It includes all the semi-colons generally when implementing in fun I Cope's most people prefer while

36

00:03:02,190  -->  00:03:08,330
loops or follows a semantically while loops are considered to be more clear.

37

00:03:08,330  -->  00:03:10,770
However that's the case for infinite blocks.

38

00:03:11,210  -->  00:03:16,640
But in all other situations if both front and why Looks are applicable then a for loop is preferable

39

00:03:16,650  -->  00:03:16,880
.

40

00:03:17,830  -->  00:03:23,620
This is also recommended by one of the effective July dumps and will be discussed later on that's about

41

00:03:23,620  -->  00:03:24,000
it.

42

00:03:24,040  -->  00:03:25,610
That's all there is to why Lopes
