This repository has been archived by the owner on Aug 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit cd5aed5
Showing
3 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
void gradePrompt(int gradeNumber, float* grade) { | ||
*grade = 0; | ||
|
||
printf("Digite a nota do aluno %d: ", gradeNumber + 1); | ||
scanf("%f", grade); | ||
} | ||
|
||
float calculateAverage(float grades[], int studentAmount) { | ||
float average = 0; | ||
|
||
for(int i = 0; i < studentAmount; i++) { | ||
average += grades[i]; | ||
} | ||
|
||
average = average / studentAmount; | ||
|
||
return average; | ||
} | ||
|
||
float highestGrade(float grades[], int studentAmount) { | ||
float highestGradeFound = 0; | ||
|
||
for(int i = 0; i < studentAmount; i++) { | ||
if(i == 0) highestGradeFound = grades[i]; | ||
|
||
if(grades[i] > highestGradeFound) highestGradeFound = grades[i]; | ||
} | ||
|
||
return highestGradeFound; | ||
} | ||
|
||
float lowestGrade(float grades[], int studentAmount) { | ||
float lowestGradeFound; | ||
|
||
for(int i = 0; i < studentAmount; i++) { | ||
if(i == 0) lowestGradeFound = grades[i]; | ||
|
||
if(grades[i] < lowestGradeFound) lowestGradeFound = grades[i]; | ||
} | ||
|
||
return lowestGradeFound; | ||
} | ||
|
||
int main() | ||
{ | ||
int studentAmount = 0; | ||
|
||
printf("Digite o numero de alunos: "); | ||
scanf("%d", &studentAmount); | ||
|
||
float grades[studentAmount]; | ||
|
||
for(int i = 0; i < studentAmount; i++) { | ||
gradePrompt(i, &grades[i]); | ||
} | ||
|
||
printf("Media das notas: %.2f \n", calculateAverage(grades, studentAmount)); | ||
printf("Nota mais alta: %.2f \n", highestGrade(grades, studentAmount)); | ||
printf("Nota mais baixa: %.2f \n", lowestGrade(grades, studentAmount)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<h1 align=center>🔎 Análise de Notas</h1> | ||
|
||
# 📖 Descrição do Exercício | ||
|
||
Você vai criar um programa em C que utiliza arrays e funções para calcular e analisar | ||
as notas de uma turma de alunos. O programa deve realizar as seguintes tarefas: | ||
|
||
1. Entrada de Dados | ||
|
||
- [x] Solicitar ao usuário o número de alunos na turma. | ||
- [x] Ler as notas de cada aluno e armazená-las em um array. | ||
|
||
2. Funções a serem implementadas | ||
|
||
- [x] Função para calcular a média das notas. | ||
- [x] A função deve receber o array de notas e o número de alunos como parâmetros e retornar a média das notas. | ||
- [x] Função para encontrar a nota mais alta. | ||
- [x] A função deve receber o array de notas e o número de alunos como parâmetros e retornar a nota mais alta. | ||
- [x] Função para encontrar a nota mais baixa. | ||
- [x] A função deve receber o array de notas e o número de alunos como parâmetros e retornar a nota mais baixa. | ||
|
||
3. Saída de Dados | ||
- [x] Mostrar a média das notas, a nota mais alta e a nota mais baixa para o usuário. | ||
|
||
## 💻 Como rodar o projeto | ||
|
||
Para gerar o binário do projeto, eu utilizo gcc da seguinte maneira | ||
|
||
```bash | ||
gcc -o app main.c | ||
``` | ||
|
||
Para rodar de fato, utilizamos a sintaxe abaixo | ||
|
||
```bash | ||
./app | ||
``` | ||
|
||
O nome `app` é genérico e pode ser alterado para o que desejar. | ||
|