I didnt understand the working of 2d array nested loop example

I didnt understand the working of 2d array nested loop example

Hello Saurabh, if you are asking about that max question that Bhaiya discussed to print a pattern then pls understand it like,
So max(a,b,c,d…) it is a function that will give us the maximum value out of the values provided to it.
Let’s try to dry run this code:

there are 2 loops counter x and y. x runs for 5 times and y runs 5 times for every x means 5*5 =25 times

n=5

for x=0
for x=0, y=0
print(max(1,1,5,5)) => 5
for x=0 y=1
print(max(1,2,5,4)) => 5
for x=0 y=2
print(max(1,3,5,3)) => 5
for x=0 y=3
print(max(1,4,5,2)) => 5
for x=0 y=4
print(max(1,5,5,1)) => 5

output => 5 5 5 5 5

for x=1
for x=1, y=0
print(max(2,1,4,5)) => 5
for x=1 y=1
print(max(2,2,4,4)) => 4
for x=1 y=2
print(max(2,3,4,3)) => 4
for x=1 y=3
print(max(2,4,4,2)) => 4
for x=1 y=4
print(max(2,5,4,1)) => 5

output now: -
5 5 5 5 5
5 4 4 4 5

Similarly for all the iteration.
I hope it is clear to you. In case it is clear to you pls mark it as resolve and provide the rating as well as feedback so that we can improve ourselves.
In case there is still some confusion pls let me know, I will surely try to help you out.
Thanks :slight_smile:
Happy Coding !!