Variables, DECLARE and CONSTANT · المتغيرات، DECLARE وCONSTANT
A variable stores a value
- A variable holds a value you can use and change.
- The arrow
←puts a value into a variable (this is assignment). - On your keyboard, type
<-(less-than, minus) — it means the same as←.
المتغير يخزن قيمة
- المتغير يحمل قيمة يمكنك استخدامها وتغييرها.
- السهم
←يضع قيمة داخل متغير (هذا هو الإسناد). - على لوحة المفاتيح، اكتب
<-(أصغر من، علامة الطرح) — إنه يعني نفس←.
Age ← 16
OUTPUT Age // → 16
OUTPUT "Age" // → Age
DECLARE names the type
DECLAREstates a variable's name and its data type.- It is good style to declare a variable before you use it.
DECLARE يُعرّف النوع
DECLAREيحدد اسم المتغير ونوع البيانات الخاص به.- من الجيد أن تُعلّن متغيرًا قبل استخدامه.
DECLARE Count : INTEGER
Count ← 0
OUTPUT Count // → 0
You can change a variable
- Assign again to give a variable a new value.
- The right-hand side is worked out first, then stored.
يمكنك تغيير متغير
- أعد التخصيص لإعطاء المتغير قيمة جديدة.
- يتم حساب الطرف الأيمن أولاً، ثم يُخزن.
Total ← 10
Total ← Total + 5
OUTPUT Total // → 15
Watch the value change · راقب تغير القيمة
← puts a value into a box. Assign again, and the box holds the new value. · ← يضع قيمة في صندوق. أعد التعيين، وسيحتوي الصندوق على القيمة الجديدة.
A constant does not change
- A constant is a name for a value the program must not change, such as a pass mark or an hourly rate.
- The 2026–2028 syllabus writes
CONSTANT HourlyRate ← 6.50— the arrow, then a literal only. - If the number changes next year, you edit that one line and every use of the name follows.
الثابت لا يتغير
- الثابت هو اسم لقيمة لا يجب أن يغيرها البرنامج، مثل درجة النجاح أو المعدل الساعي.
- منهج 2026–2028 يكتب
CONSTANT HourlyRate ← 6.50— السهم، ثم حرفية فقط. - إذا تغير الرقم في العام القادم، تعدّل هذا السطر الواحد ويتبع كل استخدام للاسم.
CONSTANT PassMark ← 50
OUTPUT PassMark // → 50
Watch out
←(or<-) means store into. It is not the=used to test equality.- A variable keeps its last value until you assign a new one.
OUTPUT Ageprints the number in the box.OUTPUT "Age"prints the word Age.
انتبه
←(أو<-) تعني تخزين داخل. وهي ليست=المستخدمة لـاختبار المساواة.- يحتفظ المتغير بآخر قيمة له حتى تقوم بتعيين قيمة جديدة له.
OUTPUT Ageيطبع الرقم داخل الصندوق.OUTPUT "Age"يطبع كلمة Age.
Common mistakes
DECLARE <identifier> : <data type>before you use a variable.- A constant is
CONSTANT <identifier> ← <value>. Assign a variable with←.
أخطاء شائعة
DECLARE <identifier> : <data type>قبل استخدام متغير.- الثابت هو
CONSTANT <identifier> ← <value>. خصّص متغيرًا باستخدام←.
Now you try
- Type
<-for the←arrow. - Press Run to see the output, then Check answer.
الآن جرب بنفسك
- اكتب
<-لسهم←. - اضغط على Run لرؤية المخرجات، ثم اضغط على Check answer.
Put 16 into a variable called Age, then OUTPUT it. (Type <- for the ← arrow.) · ضع 16 في متغير اسمه Age، ثم OUTPUTه. (اكتب <- للـ ← سهم.)
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.
DECLARE a variable Price as INTEGER, set it to 3, then OUTPUT Price * 4 (the answer is 12). · DECLARE متغير Price كـ INTEGER، ضعه في 3، ثم OUTPUT Price * 4 (الجواب هو 12).
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.
Set Total to 10, then add 5 to it, then OUTPUT Total (the answer is 15). · اجعل Total يساوي 10، ثم أضف إليه 5، ثم OUTPUT Total (الجواب هو 15).
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.
Declare a constant PassMark with the value 50, using ←, then OUTPUT it. · أعلن ثابتاً PassMark بالقيمة 50، باستخدام ←، ثم OUTPUTه.
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.