Lesson 10 of 34

for loop: மீண்டும் மீண்டும் செய்தல்The for Loop

8 min 25 XP

for loop-ல் மூன்று பகுதிகள்: தொடக்கம் (int i = 1), condition (i <= 5), மாற்றம் (i++). Condition true ஆக இருக்கும் வரை loop இயங்கும்.

A for loop has three parts: a start (int i = 1), a condition (i <= 5) and a step (i++). The loop keeps running while the condition is true.

Example: edit me and press Run

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

Loop-க்கு வெளியே ஒரு variable-ஐ உருவாக்கி, loop உள்ளே மதிப்புகளைச் சேர்க்கலாம். இதுவே கூட்டுத்தொகை (sum) கணக்கிடும் வழி.

Create a variable before the loop and add to it inside the loop. This is how we calculate totals.

Example: edit me and press Run

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

Loop உள்ளே உருவாக்கப்பட்ட i, loop-க்கு வெளியே கிடைக்காது.

A variable declared in the loop, like i, does not exist outside the loop.

Challenge

+25 XP

ஒரு எண் n-ஐப் படித்து அதன் பெருக்கல் வாய்ப்பாட்டை (multiplication table) 1 முதல் 10 வரை print செய்யுங்கள். Input: 7 Output: 7 x 1 = 7 7 x 2 = 14 ... 7 x 10 = 70

Read a number n and print its multiplication table from 1 to 10. Input: 7 Output: 7 x 1 = 7 7 x 2 = 14 ... 7 x 10 = 70

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