Now we will take two quizzes regarding nested loops and conditional statements. In your opinion, what will this first code print upon execution ? The correct answer is D. Let us see why. The code's first "for" instruction declares a variable i intialized to 0. The condition is "i strictly less than 3". And the increment statement is plus plus i. i will thus take the values 0, 1 and 2. The first time we enter the loop, i is 0. Now we move on to this second "for" instruction, within the first one. This second "for" instruction declares a variable j, intialized to 0. The condition is "j strictly less than 4". The increment statement is plus plus j. j will thus take the values 0, 1, 2, and 3. The first time we enter the "for j" loop, this one, j will have the value 0. Now we execute the instructions within this "for j" loop, starting with this conditional statement and testing the condition "i equal to j". i is 0. j is 0 aswell. The condition is therefore true and we proceed to execute this instruction here, which prints an asterisk. By the way, there is no double less-than sign-endl at the end of this line. Thus, the next print will be displayed here, right after the asterisk. We skip the "else" part of the conditional statement. We reach the end of the "for j" loop which iterates on j and jump back here. j takes the value 1 and we continue within the "for j" loop. First executing the conditional statement and testing the condition "i equal to j". i is 0. This time, j is 1. The condition is thus false. We execute this part of the conditional statement, thus printing j's value. So, we print 1 here. We reach the end of the "for j" loop and, again, jump back here. j will now take the value 2. We will print 2. Then j will take the value 3 and we will print this 3. Finally, we exit de "for loop" which iterates on j and reach this instruction here, triggering a line break. Therefore, the next printing will occur here. We reach the end of the "for i" loop and jump back here. i will take the value 1. Now we execute these instructions again, within this here "for loop". We restart here and j will be initialized to 0 again. We execute the instructions within the "for j" loop and we test this condition : "i equal to j". i has the value 1. j has the value 0. The condition is false and we thus print j's value, that is, 0. At this point, we jump back here and j will take the value 1. We resume within the "for j" loop and execute this conditional statement, namely the condition "i equal to j". This time, i has the value 1 and so does j. The condition is thus true. And we can execute this part of the conditional statement : printing an asterisk. We jump back here, and continue within the "for j" loop. You should now be convinced that this will eventually be printed. The second quiz is a little bit harder. Please note that, here, we're using the value of the variable i, declared within the first "for loop". In your opinion, what is the correct answer ? The correct answer is A. Let us explain why. As before, the first "for loop" initializes a variable i to zero. The condition is "i strictly less than 3". And the increment statement is plus plus i. Just as before, i will take the values 0, 1 and 2. We begin by entering the "for i" loop, with i being 0. We execute this instruction here, which is another "for loop" initializing a variable j to 0. The condition is "j strictly less than i". i is 0. j is 0 as well. Thus this condition is false. Thus we exit this loop immediately and end up here. In other words, we simply generate a line break, which we will represent this way. Now we jump back here. i will take the value 1, j is initialized to 0. The condition is now "j strictly less than i" while i is 1. Thus, j will take the value 0. We will then exit the loop immediately. For now, j is 0. We'll execute this instruction here. That is, printing j's value : 0. We exit the loop and reach this instruction causing a line break. We are now at the end of the "for i" loop and come back here. i will take the value 2. We enter the "for i" loop and execute this instruction "for" which once again initiliazes j to 0. The condition is now "j strictly less than 2". Thus, j will take the values 0 and 1. We start with j, having the value 0 and execute this "cout" instruction . namely, we print j's value, that is 0. We reach the end of the "for j" loop and come back here with j now being 1. We will execute this instruction, printing j's value, that is 1 and exit the loop. Then, we'll execute this instrution here, generating a line break. We reach the end of the "for i" loop. i now has the value 3. The condition is thus false and we exit the loop, reaching the end of the code. We clearly see that we've printed the given result.