Les trois commandes du cinéma sont dans orders, chacune avec un film, un nombre de billets et un prix. Affiche une ligne par commande, comme Up: 2 x 9 = 18, et ajoute son coût à total. La ligne Total: de la fin est déjà écrite.
Up: 2 x 9 = 18 Coco: 3 x 8 = 24 Wall-E: 1 x 12 = 12 Total: 54
#include <stdio.h>
struct Order {
char film[20];
int tickets;
int price;
};
int main(void) {
struct Order orders[] = {
{"Up", 2, 9},
{"Coco", 3, 8},
{"Wall-E", 1, 12}
};
int total = 0;
for (int i = 0; i < 3; i++) {
// ton code ici: calcule le coût de cette commande, affiche sa ligne, ajoute-le à total
}
printf("Total: %d\n", total);
return 0;
}
Exécuter teste les exemples. Quand ils sont bons, appuie sur Envoyer.