LESSON 04 OF 52 · CHAPTER 01
Arithmetic
Integer operators and precedence
04-arithmetic.srp
// Multiplication binds more tightly than addition.
print(1 + 2 * 3);
print((1 + 2) * 3);
print(-7 / 2);
print(-9223372036854775808);
print("Arithmetic complete.");
stdout
7
9
-3
-9223372036854775808
Arithmetic complete.
Write what you expect this program to print. Check prediction for a line-level hint without revealing the answer, or reveal the verified output when ready. This checks displayed text only; it does not run Scarp or save your input.
UNDERSTAND THE CODE
Explanation & practice
What this example teaches
Integer operators and precedence
Expected behavior
Sequence shown in stdout
Practice: Read the source before looking at the output. Predict the values and their order, then use the pinned compiler to execute this lesson and compare the exact fixture. Identify which operation produces the result.
अंकगणित और प्राथमिकता
जोड़ तथा गुणा का क्रम परिणाम बदल सकता है। कोष्ठक का प्रयोग करके गणना की प्राथमिकता स्पष्ट करें।
अभ्यास: पहली दो अभिव्यक्तियों की तुलना करें।
Explanations are sourced from the project's English chapter guide and हिन्दी अध्याय. The Scarp program and output are unchanged.
LEARNING PROGRESS
Keep your place
Mark this lesson complete when you are ready.
Only saved in this browser. No account or tracking.
TRY IT LOCALLY
Verify, then execute
Use the pinned compiler from the course root. Keep any imported _support files next to the source.
scarp verify examples/01-basics/04-arithmetic.srp
scarp exec examples/01-basics/04-arithmetic.srpThe website does not run code. Read the CLI guide ↗
Pinned compiler: Scarp v0.0.6-alpha.3
· ceff07d9014f. No simulated output.