Below is the code to print out the 2-table:
We start off by initializing two variables ‘i’ and ‘n’. ‘i’ is initialized to 1 and ‘n’ is initialized to ‘2’.
Inside the while loop, since the ‘i’ value goes from 1 to 10, the loop iterates 10 times.
Initially n*i is equal to 2*1, and we print out the value.
Then, ‘i’ value is incremented and n*i becomes 2*2. We go ahead and print it out.
This process goes on until i value becomes 10.