Hello and welcome to the golden programming language course in this session.
We want to talk about the other areas concepts.
Iterate over and add a you can iterate over and add a elements in different ways for loop, for accessing
great elements, range for accessing added elements.
Rains for accessing every element and do not display index.
And range in Lou, as if look.
First, we want to talk about for Loop, for accessing added elements.
Now go to Waskow and illustrate how to use Falou first, clear the last quote.
Save the project defined an 80 and initialize it, for the example, in Annie Hall and equals S-Corp
bracket set five value for the length of edit and end for the type of array and calibre rockets and
initialize the value one two, three four and comma fine.
Now display the values of an eight by four loop.
Formed by calling equals zero I less than Len and I four create the condition for loop you can use from
length of arable land function and then I plus plus display that anybody by index.
So write these codes FP and add a high school breakfast and sit.
I very well here for return the value of each index.
Save the projects and execute the code first.
Go to the project folder.
See the array and draw on the project.
Now we can see the output.
In this case, one unit is added each time by A-plus, plus plants and fish to add eight elements value
by access to index of it, and we could iterate between added elements.
Now go to a slide and continue in this case, we want to talk about range for accessing added elements
and range for accessing added elements without index and range info low as a view.
Range.
The foreign statements supports one additional form that uses the key word range to iterate over the
next version that evaluates to an array a slice map extreme or Channon range victory, and this slices
it returns the index of the item as integer.
With maps, it returns the key of the next key value chain and range either returns one value or two.
You can see the syntax index is the index of the value we are accessing.
Value is the actual value you have on each iteration, and data holds the data structure whose values
will be accessed in the loop.
Now go to the school and do some example.
First, Hillier, the last call and comment this followed and iterate these very bad by the arrange
for.
Index common value.
Column he calls Ranj name of variable in array.
And display each element by index and value of FP.
Index.
And Value said the project executed the cold.
Now we can see the output and we could display each element of at a Y index and value.
In today, we can display just value by Iranians in follow up and do not display in their 40s or sit
on the score instead of index and solely print the value.
Now, clearest in the last full comment, this court
and to the following fall, instead of index, we sit on the risk for common value calling equals ranj
abbreviated entry and print, a value worth p value.
Save the project and execute the code.
Now we can see the output, the value of each element has created one two three four five and they could
display the value of each element without index by the range.
In the fourth day, we can use the range info loop as a viable loop.
Now here is screen comment, this court
and right there range in loop as a wire loop first define a very idea like J Call it equals zero is
as a counter and create a followed by range, full range and name or variable inside a display the value
of any in each iteration.
FP
inside a briefcase and set j variable here for which the variable value and after each iteration plus
plus JW Marriott and J Plus Plus Deformity Code said the project can execute the code.
Now we can see the output one, two, three, four five, and we could use the range in follow up advice,
look, in order not to prolong the time of this session, we will finish it and we will continue the
content in the next session.
Goodbye.