1 00:00:02,000 --> 00:00:06,720 Let us proceed and check out how do we use do while loop in Gears of Cartland. 2 00:00:06,770 --> 00:00:11,430 Now the syntax of doing a loop in case of Gorlin is similar to darte of Java. 3 00:00:11,460 --> 00:00:15,330 So here this is our cantor very well and I. 4 00:00:15,540 --> 00:00:20,070 So now after this I will simply define do while loop. 5 00:00:20,260 --> 00:00:21,160 Now insert this. 6 00:00:21,180 --> 00:00:22,320 I will simply print. 7 00:00:22,510 --> 00:00:25,350 Let's see the value of i. 8 00:00:25,590 --> 00:00:27,900 And then I was simply increment the Gounder. 9 00:00:27,930 --> 00:00:28,860 I blissfulness. 10 00:00:28,860 --> 00:00:32,780 Now the question arises where we're actually doing the condition check. 11 00:00:32,820 --> 00:00:36,860 Now in case of do loop we actually do the conditions at the end. 12 00:00:36,960 --> 00:00:42,420 So here I was simply write a while and then I will do the condition check. 13 00:00:42,450 --> 00:00:45,630 Let's see it is smaller than 10 right. 14 00:00:45,970 --> 00:00:49,150 Or I is more than equal to 10. 15 00:00:49,410 --> 00:00:52,340 And now let us run the called. 16 00:00:52,430 --> 00:01:00,680 So the output again we get 1 to 10 right and now again if I ask you to print all the even numbers with 17 00:01:00,680 --> 00:01:07,510 the help of Dubai Velu present between 1 and then so far that again inside there do very low body. 18 00:01:07,610 --> 00:01:17,030 I was interviewed Read the if condition if I Martinus to is equal to equal to zero then only bring the 19 00:01:17,030 --> 00:01:21,130 value that is put into print only that even numbers. 20 00:01:21,290 --> 00:01:23,410 And now let's just read the code. 21 00:01:23,810 --> 00:01:26,760 So here we go to 4 6 8 and 10. 22 00:01:26,930 --> 00:01:34,530 So the syntax is almost same as that of any other programming language as part of C C++ and act of Java. 23 00:01:35,620 --> 00:01:37,410 So this is all for this video. 24 00:01:39,200 --> 00:01:44,990 And again if you are a beginner and want to know how the do while loop actually works then please continue 25 00:01:44,990 --> 00:01:46,180 watching this video. 26 00:01:46,370 --> 00:01:49,680 So here this is a syntax of their do value here. 27 00:01:49,750 --> 00:01:56,010 The first initialize the counter and then the right does Sendak's do vile condition. 28 00:01:56,030 --> 00:02:02,510 Now insert there do we have a body there we actually put our code and then in agreement or decrement 29 00:02:02,510 --> 00:02:07,430 the counter and same way on the left hand side I have some example for you. 30 00:02:07,850 --> 00:02:14,060 So here I will simply print hello three times and here we will check out how they do value simply put 31 00:02:14,060 --> 00:02:14,470 in. 32 00:02:14,550 --> 00:02:17,250 Hello three times in the output console. 33 00:02:17,270 --> 00:02:21,040 So as usual the output we are getting three times. 34 00:02:21,050 --> 00:02:24,020 So at least three times the loop will be executed. 35 00:02:24,020 --> 00:02:29,040 So let us check out the sequence of operations such as in Gears of W. 36 00:02:29,090 --> 00:02:35,260 The first execute the called then increment the counter and then check the condition right. 37 00:02:35,300 --> 00:02:41,690 So this is the sequence of ne'er do well you know then the loop one starts the call executes that is 38 00:02:41,750 --> 00:02:43,600 we get hello in the output. 39 00:02:43,640 --> 00:02:50,330 So we simply print hello and then Ingram and the counter and then the counter variable becomes one and 40 00:02:50,330 --> 00:02:53,830 then finally check the condition which becomes true. 41 00:02:54,020 --> 00:02:55,200 Now make a note here. 42 00:02:55,310 --> 00:02:57,580 We are checking the condition at the end. 43 00:02:57,710 --> 00:03:00,740 So no matter if the condition is true or false. 44 00:03:00,770 --> 00:03:04,420 At least we will execute our called body at least once. 45 00:03:04,430 --> 00:03:10,730 So once the condition becomes true and it becomes one then this equal to 1 simply comes our this loop 46 00:03:10,790 --> 00:03:12,340 to wait again. 47 00:03:12,350 --> 00:03:17,390 We put in the value as hello and then increment the counter to do. 48 00:03:17,510 --> 00:03:21,980 And then again check that our nation are at the end which again becomes true. 49 00:03:21,980 --> 00:03:24,530 Now here the counter value becomes two. 50 00:03:24,530 --> 00:03:30,020 Now this going of value again comes in that third loop where we first put in the value. 51 00:03:30,230 --> 00:03:33,390 And again Ingram and the counter to three. 52 00:03:33,400 --> 00:03:38,140 Now this time this tree is actually not smaller than three. 53 00:03:38,150 --> 00:03:45,520 So the condition here becomes far as but please note is that since the condition is false. 54 00:03:45,550 --> 00:03:49,800 But before checking the condition we have simply printed Hello. 55 00:03:49,900 --> 00:03:50,770 Right here. 56 00:03:50,780 --> 00:03:51,580 Print Hello. 57 00:03:51,670 --> 00:03:54,900 So at the end of third loop if the condition becomes false. 58 00:03:54,970 --> 00:03:59,470 It doesn't matter because we have already printed hello in the output. 59 00:03:59,530 --> 00:04:07,190 So once it becomes three this by two in is shared the for loop but this does NOT happens because the 60 00:04:07,190 --> 00:04:10,780 condition is false and the loop terminates. 61 00:04:10,820 --> 00:04:14,210 So this is how their due value works in case of Cartland.