44 lines
1.0 KiB
C++
44 lines
1.0 KiB
C++
/*
|
|
* Programme d'affichage d'une moyenne de notes
|
|
* Par Florian Goussot
|
|
* BTS CIEL 2e année
|
|
* Fait le 05/11/2024 à Nancy
|
|
*/
|
|
#include <stdio.h>
|
|
#include <conio.h>
|
|
#include <stdlib.h>
|
|
|
|
int main(void) {
|
|
do {
|
|
system("cls");
|
|
printf_s("\t\t\tAffichage d'une moyenne de notes\n");
|
|
printf_s("Donnez le nombre de notes : ");
|
|
double notes = 0, max = 0, min = 20;
|
|
int total_notes = 0;
|
|
scanf_s("%i", &total_notes);
|
|
for (int i = 1; i <= total_notes; i++) {
|
|
printf_s("Entrez une note :");
|
|
float note = 0;
|
|
scanf_s("%f", ¬e);
|
|
if (note >= 0 && note <= 20) {
|
|
if (note > max) {
|
|
max = note;
|
|
}
|
|
if (note < min) {
|
|
min = note;
|
|
}
|
|
notes += note;
|
|
}
|
|
else {
|
|
i--;
|
|
printf_s("Veuillez entrer une note comprise entre 0 et 20 !\n\n");
|
|
}
|
|
}
|
|
notes /= total_notes;
|
|
printf_s("La moyenne est de %.2f\n", notes);
|
|
printf_s("La note la plus basse est de %.2f\n", min);
|
|
printf_s("La note la plus élevée est de %.2f\n", max);
|
|
printf_s("\n\nAppuyez sur Echap pour quitter...");
|
|
} while (_getch() != 27);
|
|
return 0;
|
|
} |