Trois avis : 3 étoiles, 5 étoiles et 1 étoile. La fonction stars(n) affiche une ligne de n * ; elle est void, donc elle affiche seulement et ne renvoie rien. Complète la ligne à l’intérieur, puis appelle-la dans main pour chaque note.
*** ***** *
#include <stdio.h>
void stars(int n) {
for (int i = 0; i < n; i++) {
// ton code ici: affiche un *
}
printf("\n");
}
int main(void) {
int ratings[] = {3, 5, 1};
for (int i = 0; i < 3; i++) {
// ton code ici: appelle stars avec cette note
}
return 0;
}
Exécuter teste les exemples. Quand ils sont bons, appuie sur Envoyer.