Learning Algorithms: From Variables to Loops (in French with English and Arabic Descriptions)

A step-by-step guide to understanding basic algorithm components.
Algorithms are fundamental to programming and solving problems efficiently. Here, we’ll cover the basics of algorithms, from understanding variables to using loops to create repetitive tasks. Each example is presented in pseudocode in French to help explain core concepts.
1. Variables
Variables are used to store information that can be reused and manipulated in an algorithm. They are assigned a name and a value.
Description (English): In this step, we create a variable and assign it a value.
وصف (بالعربية): في هذه الخطوة، نقوم بإنشاء متغير وتحديد قيمة له.
// Créer une variable nommée "age" et lui assigner la valeur 25
entier age = 25
2. Input and Output
Input and output allow users to interact with an algorithm by entering data and receiving feedback.
Description (English): Here, we prompt the user to enter their age and then display it.
وصف (بالعربية): هنا، نطلب من المستخدم إدخال عمره ثم نعرضه.
// Demander l'âge de l'utilisateur
afficher "Entrez votre âge :"
lire age
afficher "Votre âge est : ", age
3. Conditional Statements (If-Else)
Conditional statements check specific conditions and execute code accordingly.
Description (English): This example checks if the user is an adult (18 or older) and displays a message accordingly.
وصف (بالعربية): يتحقق هذا المثال ما إذا كان المستخدم بالغًا (18 عامًا أو أكثر) ويعرض رسالة بناءً على ذلك.
// Vérifier si l'utilisateur est majeur
si age >= 18 alors
afficher "Vous êtes majeur."
sinon
afficher "Vous êtes mineur."
fin si
4. Loops (For Loop)
Loops repeat a block of code a certain number of times, which is useful for tasks requiring repetition.
Description (English): This example uses a
for
loop to count from 1 to 5, displaying each number.
وصف (بالعربية): يستخدم هذا المثال حلقة
for
للعد من 1 إلى 5 وعرض كل رقم.
// Boucle pour compter de 1 à 5
pour entier i = 1 à 5 faire
afficher i
fin pour
5. While Loop
The while
loop executes as long as a specific condition is
true, making it ideal for indefinite repetition until the condition changes.
Description (English): In this example, the
while
loop continues to display a message as long as the age is
less than 18.
وصف (بالعربية): في هذا المثال، تستمر حلقة
while
في عرض الرسالة طالما كان العمر أقل من 18.
// Boucle tant que l'âge est inférieur à 18
tant que age < 18 faire
afficher "Vous êtes encore mineur."
afficher "Entrez à nouveau votre âge :"
lire age
fin tant que
Conclusion
Learning variables, conditional statements, and loops are foundational to mastering algorithms. With practice, these basic structures will allow you to create more complex algorithms and solve a variety of programming problems.