CHAPTER 02 · 4 LESSONS

02 · Control flow

Conditions are booleans; a branch body has its own scope. Loops also support break and continue.

YOUR CHAPTER LEARNING PATH · सीखने का क्रम

Read. Check. Build.

Three linked steps using real Scarp source and verified output.

  1. Read the lessons · पाठ पढ़ें

    Work through all 4 verified examples. Save optional local lesson progress as you learn; this does not certify code execution.

    Start with Decisions ↗

    Lesson tracking is optional and only available when browser storage works.

  2. Check understanding · समझ जाँचें

    Try 3 bilingual questions linked directly to their original source and expected output. No quiz score is stored.

    Review all three questions here · यहाँ अभ्यास करें ↓
  3. Write Scarp · कोड लिखें

    Edit the real starter locally, compare output with the compiler-verified goal, and use the hint or tested solution when needed.

    Open Sum loop indices lab ↗

Lesson completion is voluntary local tracking. Passing a quiz or lab is not automatically recorded or claimed by this website. The Scarp compiler runs locally, not in your browser.

Lessons in this chapter

Practice this chapter · इस अध्याय का अभ्यास करें 3 bilingual, compiler-evidenced questions

Answer all three questions using the checked-in lessons. Feedback runs only in your browser; there is no stored score, automatic lesson completion or Scarp execution. Answers remain readable without JavaScript.

Question 1 of 3 · Decisions · View source and recorded output ↗

SOURCE-BACKED SELF-CHECK · स्रोत-आधारित अभ्यास

Quick checkpoint / त्वरित अभ्यास

Which grade is printed when score is 73?जब score का मान 73 है, तो कौन-सा ग्रेड प्रिंट होगा?

Reveal the source-backed answer / सही उत्तर देखें

B — 73 does not satisfy score >= 90, but it satisfies score >= 60 and score < 90, so grade becomes B.B — 73, 90 से कम और 60 से अधिक या बराबर है। इसलिए elif की शर्त सही होती है और grade का मान B बनता है।

This question checks understanding of a recorded compiler output. It does not run Scarp in the browser. यह प्रश्न सत्यापित आउटपुट पर आधारित है; ब्राउज़र में Scarp नहीं चलता।

Question 2 of 3 · While Loops · View source and recorded output ↗

SOURCE-BACKED SELF-CHECK · स्रोत-आधारित अभ्यास

Quick checkpoint / त्वरित अभ्यास

What total does the while loop print after skipping 3 and breaking above 5?3 को छोड़ने और 5 से ऊपर जाने पर लूप रोकने के बाद while लूप कौन-सा total प्रिंट करता है?

Reveal the source-backed answer / सही उत्तर देखें

12 — The loop adds 1, 2, 4 and 5. It skips 3 with continue and exits at 6, so the sum is 12.12 — लूप 1, 2, 4 और 5 को जोड़ता है। continue से 3 छूट जाता है और 6 पर break होता है, इसलिए योग 12 है।

This question checks understanding of a recorded compiler output. It does not run Scarp in the browser. यह प्रश्न सत्यापित आउटपुट पर आधारित है; ब्राउज़र में Scarp नहीं चलता।

Question 3 of 3 · Repeat · View source and recorded output ↗

SOURCE-BACKED SELF-CHECK · स्रोत-आधारित अभ्यास

Quick checkpoint / त्वरित अभ्यास

What total is printed when repeat skips index 2?repeat में index 2 को छोड़ने पर कौन-सा total प्रिंट होता है?

Reveal the source-backed answer / सही उत्तर देखें

8 — repeat saves the initial count of five iterations. The indices 0, 1, 3 and 4 sum to 8; assigning count = 0 does not shorten the loop.8 — repeat शुरुआत की पाँच पुनरावृत्तियाँ तय कर लेता है। index 0, 1, 3 और 4 का योग 8 है; count = 0 करने से लूप छोटा नहीं होता।

This question checks understanding of a recorded compiler output. It does not run Scarp in the browser. यह प्रश्न सत्यापित आउटपुट पर आधारित है; ब्राउज़र में Scarp नहीं चलता।

All examples are validated with Scarp v0.0.6-alpha.3. Each lesson has its own code and expected-output page.