Iteration: FOR · التكرار: FOR
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · تحتاج هذه الصفحة إلى متصفح حديث (يدعم SharedArrayBuffer). يرجى تحديث Chrome أو Edge أو Firefox أو Safari إلى أحدث إصدار.
English
FOR counts
- A count-controlled loop runs once for each integer from the start to the end, inclusive.
- The counter is an
INTEGER. - It is good practice to repeat the counter's name after
NEXT.
العربية
FOR يعد
- الحلقة التي تتحكم بالعداد تعمل مرة واحدة لكل عدد صحيح من البداية إلى النهاية، شاملاً الطرفين.
- العداد هو
INTEGER. - من الممارسات الجيدة تكرار اسم العداد بعد
NEXT.
DECLARE Total : INTEGER
Total ← 0
FOR I ← 1 TO 5
Total ← Total + I
NEXT I
OUTPUT Total
Explore · استكشف
Trace the running total · تتبع المجموع الكلي
A FOR loop repeats a set number of times. Step through and watch Total grow. · حلقة FOR تكرر عددًا محددًا من المرات. مرّ بها وانظر كيف ينمو Total.
English
STEP changes the jump
STEPsets the gap between values. It can be negative.- If the start is already past the end in the step's direction, the body does not run.
العربية
STEP يغير القفز
STEPيحدد الفاصل بين القيم. يمكن أن يكون سالباً.- إذا كانت البداية قد تجاوزت بالفعل النهاية في اتجاه الخطوة، فلن يعمل الجسم.
FOR I ← 5 TO 1 STEP -2
OUTPUT I
NEXT I
English
Watch out
NEXT Imust name the counter of this loop.- The body is indented.
NEXTlines up withFOR.
العربية
انتبه
NEXT Iيجب أن يحدد عداد هذه الحلقة.- الجسم مزاح.
NEXTيوازيFOR.
English
Common mistakes
1 TO 5includes both 1 and 5.- Do not change the counter yourself inside the body.
العربية
أخطاء شائعة
1 TO 5يشمل كلا من 1 و 5.- لا تغير العداد بنفسك داخل الجسم.
English
Now you try
- Use a
FORloop to print a run of numbers.
العربية
الآن جرب بنفسك
- استخدم حلقة
FORلطباعة سلسلة من الأرقام.
Use a FOR loop to output the numbers 1 to 5, one per line. · استخدم حلقة FOR لإخراج الأرقام من 1 إلى 5، واحدًا لكل سطر.
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.
Output 5, 3 and 1, using FOR with STEP -2. · أخرج 5، 3 و 1، باستخدام FOR مع STEP -2.
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.