Lesson 10 of 34

for Loop

8 min 25 XP

for loop के तीन हिस्से होते हैं: शुरुआत (int i = 1), condition (i <= 5) और step (i++)। जब तक condition true है, loop चलता रहता है।

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 के अंदर उसमें जोड़ते जाएँ। Totals ऐसे ही निकाले जाते हैं।

Example: edit me and press Run

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

Loop में declare किया गया variable, जैसे i, loop के बाहर मौजूद नहीं रहता।

Challenge

+25 XP

एक संख्या n पढ़ें और 1 से 10 तक उसका पहाड़ा print करें। 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.