Printing Patterns with the For Loop - Part One
(A) 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 (B) 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 (C) 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 (D) 1 2 2 3 3 3 2 2 1 (E) 1 2 3 4 5 6 7 8 9 Printing patterns is often part of the school exercises you should do when you are doing your introductory programming course. It helps you learn how to apply your brains as a programmer. Whilst many examples of how to print patterns exist online and in books, not many of them explain the step by step thinking process involved to come up with such examples. It is the aim of this post to explain how to approach problems. It is often easy for an experienced programmer to mentally figure out the whole algorithm needed to solve a given a solution even before they start writing the code. But it is usually not so with beginners. So how...