Putting it together · دمج العناصر معًا
Putting it together
- A real algorithm joins the pieces: arrays, loops and selection.
- The exam's standard methods are totalling, counting, linear search, and finding the maximum or minimum.
دمج العناصر معاً
- خوارزمية حقيقية تجمع القطع: arrays (مصفوفات)، loops (حلقات)، و selection (اختيار).
- Standard methods (الأساليب القياسية) في الامتحان هي الجمع، العد، البحث الخطي، وإيجاد القيمة القصوى أو الدنيا.
DECLARE A : ARRAY[1:5] OF INTEGER
DECLARE I, Total : INTEGER
FOR I ← 1 TO 5
A[I] ← I * 10
NEXT I
Total ← 0
FOR I ← 1 TO 5
Total ← Total + A[I]
NEXT I
OUTPUT Total
Totalling an array · جمع مصفوفة
Totalling — start at 0, then add each array item as the loop visits it. · الجمع — ابدأ من 0، ثم أضف كل عنصر من المصفوفة كلما زارته الحلقة.
Searching and counting
- Linear search: check each item, and set a flag if you find the target.
- Counting: add 1 to a counter each time a rule is true.
Searching and counting (البحث والعد)
- Linear search (البحث الخطي): تحقق من كل عنصر، وضِع flag إذا وجدت الهدف.
- Counting (العد): أضف 1 إلى counter في كل مرة تكون فيها قاعدة ما صحيحة.
DECLARE A : ARRAY[1:5] OF INTEGER
DECLARE I, Target : INTEGER
DECLARE Found : BOOLEAN
FOR I ← 1 TO 5
A[I] ← I * 10
NEXT I
Target ← 30
Found ← FALSE
FOR I ← 1 TO 5
IF A[I] = Target
THEN
Found ← TRUE
ENDIF
NEXT I
OUTPUT Found
Common mistakes
- Plan the structure before you write the pseudocode.
- Match the exam's keywords and layout exactly.
أخطاء شائعة
- خطّط للبنية قبل كتابة الكود الوهمي.
- طابق كلمات الامتحان الرئيسية والتخطيط بدقة.
Now you try
- Each task uses an array that is filled for you — write the algorithm.
- Press Check answer to test it.
الآن جرب بنفسك
- كل مهمة تستخدم مصفوفة تم ملؤها لك — اكتب الخوارزمية.
- اضغط على تحقق من الإجابة لاختبارها.
The array A is filled for you. Total all 5 values and output Total = then the total (it is 25). · تم ملء مصفوفة A لك. اجمع كل قيم 5 وأخرج Total = ثم المجموع (قيمته هو 25).
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.
The array A is filled for you. Use a linear search to set Found to TRUE if 9 is in the array, then output Found. · المصفوفة A مملوءة لك. استخدم بحثاً خطياً لجعل Found يساوي TRUE إذا كان 9 موجوداً في المصفوفة، ثم أخرج Found.
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.
The array A is filled for you. Count how many values are greater than 4, then output the count (it is 3). · المصفوفة A مملوءة لك. عد كم عدد القيم الأكبر من 4، ثم أخرج العدد (وهو 3).
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.