for the first for loop.
for example let us enter 2 for num. for(int i=1; i<=num; i++)
you are checking the num if that num is <= i. you will go through the next loop for(int j=1; j<=num; j++)
and will check if j less than or = to num will go throgh the loop until j become bigger than num. so, we will go through the second loop two times. once we finish we go back to the first loopfor(int i=1; i<=num; i++) and the i will become 2 which is true for our condition. then we will go through the second loop again for the second time and will print the star two times. then back to the first loop. Now the i is = 3 which is false which our loop going to terminate.