Regarding loops on arrays, we have already seen how to retrieve the size of the array. For that, we used a specific function called "size". There are actually many specific functions associated with dynamic arrays. We would like to introduce you to a few ones. Specific functions are always used the same way. That is, the name of the array, followed by a period (directly glued to the array's name), followed by the name of the specific function. This specific function may, for example, take arguments if need be. In the "size" function, there is no argument to be provided. However, we will see examples where we will need to provide arguments. For example, the "size" function is a specific function we will apply to an array. Here, we have declared a dynamic array called "mesure" which can contain doubles. If we want to retrieve this size, in order to use it in a variable, remember that the return type of the "size" function is "size_t". Thus we will declare a variable for example, "nombre de mesures" of the type "size_t". We will intialize it to 0, for example. Then, we may use it to retrieve the return value of this specific "size" function. There are several other specific functions related to dynamic arrays. For example, the "front" function will return a reference to the first element. For example, if we have an array called "tableau", "tableau.front() " is exactly the same thing as having written " tableau[0] ". Of course, there is the symmetry : "back " returns the last element. So, what is the last element of an array ? It is "tableau[the size of the array - 1]". Thus, the last element is : " tableau[tableau.size() - 1] ". There is also a function testing if the array is empty or not. Thus, the specific function "empty", will return a boolean-type value "true" if the array is empty and "false" if the array contains something. You have the specific function "clear" letting us suppress all the elements of the array on which we apply it. Still with the same syntax : "the_name_of_the_array.clear() ". After the call of this specific function "clear", the array is thus empty. You then have functions letting us add or suppress elements from an array. For example, the "pop_back" function lets us suppress the last element of an array. Also, the "push_back" function will add an element at the end of an array. Be reminded that we are talking about dynamic arrays here; their size can therefore vary. This means we can add or suppress elements. In order to add an element to an array, we need to indicate its value. Therefore, the "push_back" function will receive here the value we wish to add to the array. For example, let us consider a dynamic array "v", a dynamic array of doubles initialized with three values : all 4.5 For example, if we do a "pop_back" to this "v" array, "pop_back" will suppress the last element. We thus end up with an array only containing two elements. If we then do a "push_back" on this same array, pushing back a certain value, let us say 5.6, "push_back" will add an element behind this array. Our "v" array now contains 4.5 , 4.6 and 5.6 Now, if we do a second "push_back", here, with the value 6.7 this means that we add, at the end of our array, the value 6.7 The array thus now contains the four values 4.5 , 4.5 , 5.6 and 6.7 And if, finally, we do another "pop_back", "pop_back" will suppress the last element we have just added. We thus end up with this array here containing three elements. Let us take an example using several of these specific examples. This example, will revolve around writing a function initializing or reinitializing a dynamic array of integers. It will ask the user to enter values according to the following conventions. If the user enters strictly positive numbers, we will add them to the array. If the user enters 0, we will cancel everything and start all over again. If the user enters a negative number, we will simply suppress the last element of the array. For example, let us suppose we ask the user to enter three values. The user initially enters the value 5, They will thus create a dynamic array with one single element : 5, Then, the user will enter the value 2. We thus add an element : 2 Then, the user enters 0. According to our convention, we go back to square one, and restart with an empty array. Then, the user types 7. We thus recreate a dynamic array with one single element : 7. They then type 2 and -4. This is the second convention according to which, we simply suppress the last element of the array. Then, the user types 4 and 12. We have thus reached the three values we were expecting. The program stops; the array indeed contains 7, 4 and 12. We are trying to write this function. Let us remember the different steps in order to write a function. We have just clearly specified what we wish to do : the "what". The second step is to focus on the prototype. Let us look at typical examples of calls to thus function. Let us suppose we have a dynamic array of integers called "tab". We could, for example, use our function (let us call it "saisie") (TN: "saisie" means "input"). We would like to use this function, indicating "tab", and the size of the array; for example, 5 elements. For example, we could arbitrarily decide that if we do not give the size, this means that we will have to enter, for example, 4 elements. Another possible utilization example would be to have a dynamic array which is already initialized. Here, the difference is that "tab" was an empty dynamic array while "tab2" is a dynamic array containing 12 elements. In this case, we could, for example, decide to enter, in "tab2", the 12 elements. Namely, the "tab2.size()" elements it contains. Thus, we will reenter them, using its size as the second argument. Those were a few different examples on how to use the "saisie" function. We will have to write it, now. In order to write the "saisie" function. We start by wondering what its prototype should be. First of all, the parameters. As we seen in the exemplary call, we will pass an array as the first argument. Also, the second optional argument is a size. This leaves us with the following two parameters : an array and a size. What is the type of the size? We will respect the custom according to which the size of arrays are of the type "size_t". Thus, we declare "taille" of the "size_t" type. (TN: "taille" means "size"). Can the size take a default value? Yes! as we have seen in the calls, the size may have a default value. This means that we are not forced to specifiy the size. We will thus arbitrarily decide that this default size is 4. Let us move on to the first parameter. The first parameter is the dynamic array "vect". Should this array be modified by the function. Yes! it is the task of our "saisie" function to input values into the array. Since the array is modify, we will pass it by reference. Its type is a dynamic array of integers, passed by reference. We are now done with the parameters of our function. Regarding the return value, we ask ourselves the usual question : does it make sense to write " z = saisie(tab) " ? Does it make sense ? What would be the value of z in this input of an array? Personally, we fail to see what sense it makes. Therefore, the return type will be "void", meaning that the function will not return anything. We are now done with the prototype. Now, we can focus on the body of the function. To that end, we will begin with the empty vector. That means we will start by emptying the "vect" vector here received as argument (we are using the same name, here). We are going to empty it with the specific function "clear". Then, will print "saisie de" to the user. (TN : "saisie de" means "input of") and the number of elements we wish to input. Thus, "saisie de", for example 3 values. Then we will start looping as long as all the desired values have not been entered. That means, as long as the current size of the "vect" array -which we are manipulating- is strictly less than the demanded size. At this point, as long as the condition is "true", we will print "entrez la valeur". (TN: means "enter the value"). But what value? At a given time, let us suppose that the array is partially entered. For example, we have already entered the values 7 and 2. Now, we would like to ask for a third value here which will then be added. What is the position of this to-be-added value? The position of the last element is "the size of the array - 1". Thus, this upcoming position is indeed the size of the array. Thus, we will write vect.size(). And we will print "vect.size() " meaning to enter the value of the desired index. Then, we will read, through the keyboard, the value entered by the user. With these lines, we are reading this value. Now, we are to treat the three cases chosen by our convention. As we have said, if the value is negative, we need to suppress the last element. To that end, we first need to make sure that there is a last element. That means, if the value is negative and the array is not empty. Here, you can see that we are using the specific function "empty" testing if, yes or no, the array is empty. And suppressing the last element if the array is not empty. We thus write "the array is not empty" : "not vect.empty() " At this point, if these two conditions (the entered value is negative and the array is not empty) then we will, with the specific function "pop_back", suppress the last element of the "vect" array. Otherwise, if the entered value is zero, our convention is to destroy the whole array. This is done with the specific function "clear". We thus do "vect.clear() ". Otherwise, either the value is strictly positive or it is strictly negative and the array is empty. In order to eliminate this last case and only keep the case with a strictly positive value, we are testing if "val" is strictly positive. In this case, we will add the value with a "push_back". We will push back this value, adding it as the last element of the array.