Putting it together · Tout mettre ensemble
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.
Tout mettre ensemble
- Un vrai algorithme assemble les pièces : tableaux, boucles et sélection.
- Les méthodes standard de l'examen sont le total, le comptage, la recherche linéaire, et trouver le maximum ou le minimum.
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 · Somme d'un tableau
Totalling — start at 0, then add each array item as the loop visits it. · Somme — commencer à 0, puis ajouter chaque élément du tableau au fur et à mesure que la boucle y accède.
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.
Chercher et compter
- Recherche linéaire : vérifiez chaque élément, et définissez un indicateur si vous trouvez la cible.
- Comptage : ajoutez 1 à un compteur chaque fois qu'une règle est vraie.
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.
Erreurs courantes
- Planifiez la structure avant d'écrire le pseudocode.
- Correspondre exactement aux mots-clés et à la mise en page de l'examen.
Now you try
- Each task uses an array that is filled for you — write the algorithm.
- Press Check answer to test it.
À vous maintenant
- Chaque tâche utilise un tableau qui vous est rempli — écrivez l'algorithme.
- Appuyez sur Vérifier la réponse pour tester.
The array A is filled for you. Total all 5 values and output Total = then the total (it is 25). · Le tableau A est rempli pour vous. Additionner les 5 valeurs et afficher Total = puis le total (c'est 25).
Click Run to see the output here. · Cliquez sur Exécuter pour voir le résultat ici.
The array A is filled for you. Use a linear search · recherche linéaire to set Found to · à TRUE if · si 9 is in the array, then output Found. · Le tableau A est rempli pour vous. Utiliser une recherche linéaire pour affecter Found à TRUE si 9 se trouve dans le tableau, puis afficher Found.
Click Run to see the output here. · Cliquez sur Exécuter pour voir le résultat ici.
The array A is filled for you. Count how many values are greater than 4, then output the count (it is 3). · Le tableau A est rempli pour vous. Compter combien de valeurs sont supérieures à 4, puis afficher le compteur (c'est 3).
Click Run to see the output here. · Cliquez sur Exécuter pour voir le résultat ici.