1 00:00:13,490 --> 00:00:18,540 Hello and welcome to the Golang programming language course in this session. 2 00:00:18,560 --> 00:00:22,070 We want to talk about loops and control statements. 3 00:00:27,470 --> 00:00:31,410 Loops in go language go. 4 00:00:31,430 --> 00:00:39,290 Language contains only a single loop that is for loop, if for loop is a repetition control structure 5 00:00:39,530 --> 00:00:48,110 that allows us to write a loop that is executed a specific number of times and go language, these four 6 00:00:48,110 --> 00:00:53,960 loop can be used in the different forms, and the forms are simple for loop. 7 00:00:56,130 --> 00:00:58,020 Loop as infinite loop. 8 00:00:59,590 --> 00:01:01,270 And for law as vice. 9 00:01:07,120 --> 00:01:16,090 As simple for a loop, a for loop is used for iterating over cycles, that is either a slice and or 10 00:01:16,110 --> 00:01:17,880 a map or string. 11 00:01:18,310 --> 00:01:26,440 It is similar that we used in the other programming languages like C, C++, Java, C-sharp and et cetera. 12 00:01:27,220 --> 00:01:29,350 Now you can see the syntax. 13 00:01:30,950 --> 00:01:37,370 Here, the initialization a statement is optional and executes P4 for loop starts. 14 00:01:38,090 --> 00:01:45,380 The initialization, a statement is always in a simple statement like variable declarations, increment 15 00:01:45,380 --> 00:01:49,860 or assignment statements or function calls the condition. 16 00:01:49,860 --> 00:01:56,900 The statement holds a Boolean expression, which is evaluated at the start of each iteration of the 17 00:01:56,900 --> 00:01:57,290 loop. 18 00:01:57,680 --> 00:02:02,300 If the value of the conditional statement is true, then the loop executes 19 00:02:04,580 --> 00:02:06,230 increment or the post. 20 00:02:06,230 --> 00:02:13,220 The statement is executed after the body of the for loop after the post, the statement, the condition, 21 00:02:13,220 --> 00:02:15,020 the statement evaluate the gain. 22 00:02:15,290 --> 00:02:19,370 If the value of the conditional statement is false, then the loops end. 23 00:02:20,300 --> 00:02:24,860 Now let's go to the escort program to illustrate how to use for loop. 24 00:02:25,820 --> 00:02:34,700 First, go to Project Explorer, create a project folder name like loops and create a file inside. 25 00:02:34,700 --> 00:02:40,460 It's like main that go defined package name 26 00:02:44,120 --> 00:02:45,830 and defined main function. 27 00:02:51,110 --> 00:02:55,220 OK, first, define a scene per for loop four. 28 00:02:55,730 --> 00:03:04,520 So you write for define a variable for initialization, for example, I column he equals and initialize 29 00:03:04,520 --> 00:03:15,500 it by zero semicolon and defined conditions for this for loop, for example, I less than five. 30 00:03:16,880 --> 00:03:27,440 In this case, we want to print numbers between 0.5 semicolon, and if we want to increment all variable 31 00:03:27,470 --> 00:03:33,860 one by one, so we write I plus plus or can enclose kind of racist. 32 00:03:34,910 --> 00:03:37,400 And we write the statements in curly braces. 33 00:03:37,850 --> 00:03:48,950 So we write f f i equals person d put a backslash d for a tabitha's and type a message, for example, 34 00:03:48,950 --> 00:04:01,310 go pro gram language and set it back in session for go to a new line and define value that I. 35 00:04:02,870 --> 00:04:03,290 OK. 36 00:04:03,540 --> 00:04:10,550 These loops start when I equals zero and executed until I less than five. 37 00:04:11,600 --> 00:04:16,800 Now, save the project, go to a terminal and execute the program. 38 00:04:16,830 --> 00:04:24,230 First, go to Project Folder, see the loops, a screen and run the program by the comment. 39 00:04:24,230 --> 00:04:27,950 Go from dots back English made that go. 40 00:04:29,840 --> 00:04:31,850 Now we can see the output. 41 00:04:32,810 --> 00:04:40,550 We could print that go programming language five times by simper for loop from AI equals zero until 42 00:04:40,550 --> 00:04:42,260 AI equals four. 43 00:04:42,710 --> 00:04:48,170 In order not to prolong the time of decision, we will finish it and we will continue with the content 44 00:04:48,170 --> 00:04:49,280 in the next session. 45 00:04:49,400 --> 00:04:49,940 Goodbye.