Mock exams
Examens blancs
اختبارات تجريبية

Conditions and nested logic exam

Examen des conditions et de la logique imbriquée

اختبار الشروط والمنطق المتداخل

Three guided scenarios that move from simple branching to ordered checks and true nested decisions: read the statement, map the branch plan, complete the flowchart, then finish the matching C++ logic.

Trois scénarios guidés qui passent du branchement simple aux tests ordonnés puis aux décisions vraiment imbriquées : lire l'énoncé, tracer le plan des branches, compléter l'organigramme, puis terminer la logique C++ correspondante.

ثلاثة سيناريوهات موجهة تنتقل من التفرع البسيط إلى الفحوصات المرتبة ثم إلى القرارات المتداخلة فعلاً: اقرأ نص المسألة، وابنِ خطة التفرعات، وأكمل المخطط الانسيابي، ثم أتمم منطق C++ المطابق.

How this exam works

Comment fonctionne cet examen

كيف يعمل هذا الاختبار

  • Finish one scenario, then submit it to see the review and unlock the next tier.Terminez un scénario, puis soumettez-le pour voir le corrigé et débloquer le niveau suivant.أكمل سيناريو واحداً، ثم أرسله لرؤية المراجعة وفتح المستوى التالي.
  • Harmless spacing is ignored in structured fields, but exact-output prompts still require the exact visible output.Les espaces sans importance sont ignorés dans les champs structurés, mais les questions de sortie exacte demandent toujours la sortie visible exacte.يتم تجاهل المسافات غير المهمة في الحقول المنظمة، لكن أسئلة المخرجات الدقيقة ما زالت تتطلب المخرجات الظاهرة نفسها تماماً.
  • Your drafts and submitted scores are saved on this device.Vos brouillons et scores soumis sont enregistrés sur cet appareil.يتم حفظ مسوداتك ودرجاتك المرسلة على هذا الجهاز.
Scenario 1 / 3Scénario 1 / 3سيناريو ⁦1 / 3⁩ Tier 1Niveau 1المستوى ⁦1⁩

Tier 1: even or odd

Niveau 1 : pair ou impair

المستوى 1: زوجي أم فردي

Read one integer n. If n is even, print "Even"; otherwise print "Odd".

This is the most guided scenario. Keep the branch shape simple: one condition, one Yes output, one No output.

Lisez un entier n. Si n est pair, affichez "Even" ; sinon affichez "Odd".

C’est le scénario le plus guidé. Gardez une structure simple : une condition, une sortie Oui, une sortie Non.

اقرأ عددًا صحيحًا واحدًا n. إذا كان n زوجيًا فاطبع "Even"، وإلا فاطبع "Odd".

هذا هو السيناريو الأكثر توجيهًا. أبقِ شكل التفرع بسيطًا: شرط واحد، ومخرج نعم واحد، ومخرج لا واحد.

Map the branch plan

Tracez le plan du branchement

حوّل المسألة إلى خطة تفرع

Use the exact variable name, condition text, and printed words from the intended solution.
Utilisez le nom de variable, le texte de la condition et les mots affichés exacts de la solution attendue.
استخدم اسم المتغير ونص الشرط والكلمات المطبوعة الدقيقة من الحل المقصود.

Complete the decision flowchart

Complétez l'organigramme de décision

أكمل مخطط القرار

Keep each label exact. Do not add cin, cout, or semicolons.
Gardez chaque étiquette exacte. N'ajoutez ni cin, ni cout, ni point-virgule.
حافظ على كل تسمية كما هي. لا تضف cin ولا cout ولا فاصلة منقوطة.
YesNoStartInput: n[A]Output: [B]Output: [C]End
OuiNonDebutEntrée : n[A]Sortie : [B]Sortie : [C]Fin
نعملاابدأإدخال: n[A]إخراج: [B]إخراج: [C]نهاية

Finish the matching code

Terminez le code correspondant

أكمل الكود المطابق

Fill each blank with the exact condition or keyword from the intended branch.
Remplissez chaque blanc avec la condition ou le mot-clé exact du branchement attendu.
املأ كل فراغ بالشرط أو بالكلمة المفتاحية الدقيقة للتفرع المقصود.
1 int n;
2 cin >> n;
3 if ()
4 cout << "Even";
5
6 cout << "Odd";

Type the exact output

Tapez la sortie exacte

اكتب المخرجات الدقيقة

Write only the word printed on screen.
Écrivez seulement le mot affiché à l'écran.
اكتب فقط الكلمة المطبوعة على الشاشة.
1int n = 7;
2if (n % 2 == 0)
3 cout << "Even";
4else
5 cout << "Odd";
Scenario 2 / 3Scénario 2 / 3سيناريو ⁦2 / 3⁩ Tier 2Niveau 2المستوى ⁦2⁩

Tier 2: ticket check

Niveau 2 : contrôle du billet

المستوى 2: فحص التذكرة

Read one integer age. If the age is invalid (less than 0 or greater than 150), print "Invalid". Otherwise, if the age is from 13 to 19 inclusive, print "Teen ticket". In every other valid case, print "Standard ticket".

This scenario introduces an ordered chain. Reject the bad case first, then classify the remaining valid ages.

Lisez un entier age. Si l’âge est invalide (inférieur à 0 ou supérieur à 150), affichez "Invalid". Sinon, si l’âge est compris entre 13 et 19 inclus, affichez "Teen ticket". Dans tous les autres cas valides, affichez "Standard ticket".

Ce scénario introduit une chaîne ordonnée. Rejetez d’abord le cas incorrect, puis classez les âges valides restants.

اقرأ عددًا صحيحًا واحدًا age. إذا كان العمر غير صالح (أقل من 0 أو أكبر من 150) فاطبع "Invalid". وإلا، إذا كان العمر بين 13 و19 شاملًا، فاطبع "Teen ticket". وفي كل حالة صالحة أخرى اطبع "Standard ticket".

يقدّم هذا السيناريو سلسلة شروط مرتبة. ارفض الحالة الخاطئة أولًا، ثم صنّف الأعمار الصالحة المتبقية.

Write the branch checkpoints

Écrivez les points de contrôle du branchement

اكتب نقاط فحص التفرع

Use the exact variable name and exact branch conditions from the intended solution.
Utilisez le nom exact de la variable et les conditions exactes des branches de la solution attendue.
استخدم اسم المتغير الدقيق وشروط الفروع الدقيقة من الحل المقصود.

Complete the chain flowchart

Complétez l'organigramme de la chaîne

أكمل مخطط السلسلة

Fill the missing decision text exactly as it appears in the intended logic.
Complétez le texte manquant des décisions exactement comme dans la logique attendue.
أكمل نص القرارات الناقصة كما يظهر تماماً في المنطق المقصود.
YesNoYesNoStartInput: age[A]Output: "Invalid"[B]Output: "Teen ticket"Output: "Standardticket"End
OuiNonOuiNonDebutEntrée : age[A]Sortie : "Invalid"[B]Sortie : "Teen ticket"Sortie : "Standardticket"Fin
نعملانعملاابدأإدخال: age[A]إخراج: "Invalid"[B]إخراج: "Teen ticket"إخراج: "Standardticket"نهاية

Fill the exact logic tokens

Complétez les jetons logiques exacts

املأ عناصر المنطق الدقيقة

Use the exact operator or keyword in each blank. Some blanks are two words or two symbols.
Utilisez l'opérateur ou le mot-clé exact dans chaque blanc. Certains blancs contiennent deux mots ou deux symboles.
استخدم العامل أو الكلمة المفتاحية الدقيقة في كل فراغ. بعض الفراغات تتكون من كلمتين أو من رمزين.
1 int age;
2 cin >> age;
3 if (age < 0 age > 150)
4 cout << "Invalid";
5 (age >= 13 age <= 19)
6 cout << "Teen ticket";
7 else
8 cout << "Standard ticket";

Fill the printed result for each age

Complétez le résultat affiché pour chaque âge

املأ النتيجة المطبوعة لكل عمر

1int age;
2cin >> age;
3if (age < 0 || age > 150) cout << "Invalid";
4else if (age >= 13 && age <= 19) cout << "Teen ticket";
5else cout << "Standard ticket";
ageageage printedaffichéمطبوع
-2
16
42
Scenario 3 / 3Scénario 3 / 3سيناريو ⁦3 / 3⁩ Tier 3Niveau 3المستوى ⁦3⁩

Tier 3: sign and parity

Niveau 3 : signe et parité

المستوى 3: الإشارة والزوجية

Read one integer x. If x is positive, check whether it is even or odd: print "Positive even" for an even positive number, and "Positive odd" for an odd positive number. If x is not positive, print "Not positive".

This is the least scaffolded scenario. The parity test belongs inside the positive branch, not in a separate chain.

Lisez un entier x. Si x est positif, vérifiez ensuite s’il est pair ou impair : affichez "Positive even" pour un entier positif pair, et "Positive odd" pour un entier positif impair. Si x n’est pas positif, affichez "Not positive".

C’est le scénario le moins guidé. Le test de parité appartient à l’intérieur de la branche positive, pas dans une chaîne séparée.

اقرأ عددًا صحيحًا واحدًا x. إذا كان x موجبًا، فافحص بعد ذلك هل هو زوجي أم فردي: اطبع "Positive even" إذا كان العدد الموجب زوجيًا، واطبع "Positive odd" إذا كان العدد الموجب فرديًا. وإذا لم يكن x موجبًا، فاطبع "Not positive".

هذا هو السيناريو الأقل توجيهًا. فحص الزوجية ينتمي إلى داخل الفرع الموجب، وليس إلى سلسلة مستقلة.

Write the nested branch plan

Écrivez le plan du branchement imbriqué

اكتب خطة التفرع المتداخل

Use the exact outer test, inner test, and printed phrases from the intended solution.
Utilisez le test externe exact, le test interne exact et les phrases affichées exactes de la solution attendue.
استخدم الفحص الخارجي الدقيق والفحص الداخلي الدقيق والعبارات المطبوعة الدقيقة من الحل المقصود.

Complete the nested flowchart

Complétez l'organigramme imbriqué

أكمل المخطط المتداخل

Fill the two decision diamonds exactly. The second diamond lives inside the Yes branch of the first.
Complétez exactement les deux losanges de décision. Le second se trouve dans la branche Oui du premier.
أكمل معيني القرار بدقة. يقع المعين الثاني داخل فرع نعم للمعين الأول.
YesNoYesNoStartInput: x[A][B]Output: "Positiveeven"Output: "Positive odd"Output: "Not positive"End
OuiNonOuiNonDebutEntrée : x[A][B]Sortie : "Positiveeven"Sortie : "Positiveodd"Sortie : "Notpositive"Fin
نعملانعملاابدأإدخال: x[A][B]إخراج: "Positive even"إخراج: "Positive odd"إخراج: "Not positive"نهاية

Fill the nested code

Complétez le code imbriqué

أكمل الكود المتداخل

Reuse the same condition text in code. The second if is inside braces, not in an else if chain.
Réutilisez le même texte de condition dans le code. Le second if est dans des accolades, pas dans une chaîne else if.
أعد استخدام نص الشرط نفسه في الكود. تقع if الثانية داخل أقواس معقوفة، وليست ضمن سلسلة else if.
1 int x;
2 cin >> x;
3 if () {
4 if ()
5 cout << "Positive even";
6 else
7 cout << "Positive odd";
8 } else {
9 cout << "Not positive";
10 }

Type the exact output

Tapez la sortie exacte

اكتب المخرجات الدقيقة

Write only the exact words printed on screen.
Écrivez seulement les mots exacts affichés à l'écran.
اكتب فقط الكلمات الدقيقة المطبوعة على الشاشة.
1int x = 15;
2if (x > 0) {
3 if (x % 2 == 0)
4 cout << "Positive even";
5 else
6 cout << "Positive odd";
7} else {
8 cout << "Not positive";
9}