Lesson 13 of 34

Nested Loops: Star Patterns

10 min 30 XP

ఒక loop ను మరొక loop లోపల పెట్టవచ్చు. బయటి loop rows ను నియంత్రిస్తుంది, లోపలి loop ప్రతి row లోని అక్షరాలను print చేస్తుంది. Campus interviews లో pattern ప్రశ్నలు చాలా సాధారణం.

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

ప్రతి row లో ఎన్ని spaces, ఎన్ని stars ఉన్నాయో ఒక చిన్న పట్టిక రాయండి. Loop పరిమితులు స్పష్టమవుతాయి.

Challenge

+30 XP

n ను చదివి ఈ సంఖ్యల త్రిభుజాన్ని print చేయండి (n = 4): 1 1 2 1 2 3 1 2 3 4

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.