-
Notifications
You must be signed in to change notification settings - Fork 0
/
12365.c
48 lines (44 loc) · 1.05 KB
/
12365.c
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <stdio.h>
#include <locale.h>
int main() {
setlocale(LC_ALL, "");
char opcao;
float nota, soma = 0;
int contador = 0;
while (1) {
printf("\nEscolha uma opção:\n");
printf("S - Inserir mais uma nota\n");
printf("P - Ver quantas notas foram inseridas\n");
printf("N - Calcular a média aritmética das notas informadas\n");
printf("\nEscolha: ");
scanf(" %c", &opcao);
switch (opcao) {
case 'S':
case 's':
printf("Insira uma nota: ");
scanf("%f", ¬a);
soma += nota;
contador++;
break;
case 'P':
case 'p':
printf("Foram inseridas %d nota(s)\n", contador);
break;
case 'N':
case 'n':
if (contador > 0) {
float media = soma / contador;
printf("A média aritmética das notas inseridas é: %.2f\n", media);
} else {
printf("Nenhuma nota inserida.\n");
}
break;
default:
printf("Opção inválida.\n");
}
if (opcao == 'N' || opcao == 'n') {
break;
}
}
return 0;
}