--- /dev/null
+TARGET = exo2
+LIBS =
+CC = gcc
+# Enforce C11 ISO standard for now
+CFLAGS = -std=c11 -g -Wall
+LDFLAGS = -g -Wall
+
+.PHONY: default all clean
+
+default: $(TARGET)
+all: default
+
+OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c))
+HEADERS = $(wildcard *.h)
+
+%.o: %.c $(HEADERS)
+ $(CC) $(CFLAGS) -c $< -o $@
+
+.PRECIOUS: $(TARGET) $(OBJECTS)
+
+$(TARGET): $(OBJECTS)
+ $(CC) $(OBJECTS) $(LDFLAGS) $(LIBS) -o $@
+
+clean:
+ -rm -f $(TARGET) $(OBJECTS)
+
+disassemble: $(TARGET)
+ objdump -d $< | less
+
+symbols: $(TARGET)
+ objdump -t $< | sort | less
--- /dev/null
+#include <stdio.h>
+//#include <stdbool.h>
+
+//FIXME: Comment the code !!!
+
+void displayMenuEntry(int num, const char* option) {
+ printf("%d - %s\n", num, option);
+}
+
+void displayMenu() {
+ displayMenuEntry(1, "Addition");
+ displayMenuEntry(2, "Soustraction");
+ displayMenuEntry(3, "Multiplication");
+ displayMenuEntry(4, "Division");
+ displayMenuEntry(5, "Puissance");
+ displayMenuEntry(6, "Quitter");
+}
+
+int promptValue(const char* invite) {
+ int value = 0;
+ puts(invite);
+ scanf("%d", &value);
+ return value;
+}
+
+int promptOperation() {
+ displayMenu();
+ return promptValue("Veuillez saisir un choix ?");
+}
+
+int doAddition(int val1, int val2) {
+ return val1 + val2;
+}
+
+int doSubstraction(int val1, int val2) {
+ return val1 - val2;
+}
+
+int doMultiplication(int val1, int val2) {
+ return val1 * val2;
+}
+
+int doDivision(int val1, int val2) {
+ if (val2 == 0) {
+ printf("Division par zero !\n");
+ // FIXME: I'm not very fond of this convention ...
+ return 0;
+ } else {
+ return val1 / val2;
+ }
+}
+
+int doPuissance(int base, int expo) {
+ int power;
+ if ( expo == 1) {
+ power = base;
+ } else if ( expo % 2 == 0 ) {
+ power = doPuissance(base*base, expo/2);
+ } else {
+ power = base*doPuissance(base*base,(expo-1)/2);
+ }
+ return power;
+}
+
+int main() {
+ int choice = promptOperation();
+ printf("Choice: %d\n", choice);
+
+ return 0;
+}