Non-CS to Software Highway

Bridge to IT

Zero-prior-coding logic drills, the interview answers every non-CS fresher is asked, and one syntax map across C, C++, Java and Python.

Pick a pattern

Rows (n)5

Live output for n = 5

*
* *
* * *
* * * *
* * * * *

Nested loop logic

Outer loop i runs 1..n (rows). Inner loop j runs 1..i, printing one star each — so row i has i stars. Print a newline after the inner loop.

  • Running the inner loop to n instead of i — every row then prints n stars.
  • Forgetting the newline after each row.
Python
n = int(input())
for i in range(1, n + 1):
    print("* " * i)

Ready to run code for real? Open the C/C++ coding practice playground and type these patterns yourself.