calculator.bao
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# calculator.bao — calculatrice simple
fonction calculer(a, op, b):
si op == "+":
retourner a + b
sinonsi op == "-":
retourner a - b
sinonsi op == "*":
retourner a * b
sinonsi op == "/":
si b == 0:
afficher("Erreur: division par zero")
retourner nul
retourner a / b
sinon:
afficher("Opération inconnue: " + op)
retourner nul
fonction principale():
afficher("=== Calculatrice Baobab ===")
afficher("4 + 5 = " + texte(calculer(4, "+", 5)))
afficher("10 - 3 = " + texte(calculer(10, "-", 3)))
afficher("6 * 7 = " + texte(calculer(6, "*", 7)))
afficher("20 / 4 = " + texte(calculer(20, "/", 4)))
calculer(1, "%", 2)
retourner 0
principale()
Baobab Studio Terminal v1.0.0 — type 'help' for commands