Two nested loops.
The outer one iterates over the lines. The number of lines is computed from the "dinamic number".
The inner prints one line. What a line contains is computed from its index.
PS. I believe that you can edit the first post in order to move this thread into different subforum. For example, the "Beginners" forum seems much more appropriate place for your question than "UNIX/Linux Programming".