Compare commits

...

3 commits

Author SHA1 Message Date
02c7f15a66 Atualização do README 2025-03-26 13:08:47 -03:00
cedfd01328 Atualização do README da aula 6 2025-03-26 13:07:07 -03:00
9ca337fea2 atualização da aula 6 2025-03-26 13:05:41 -03:00
5 changed files with 42 additions and 11 deletions

View file

@ -25,3 +25,4 @@ qualquer distribuição.
- 17.03.2025 [[./aulas/03-tipos-de-dados/README.org][Aula 3: Tipos de dados]] ([[https://youtu.be/iMiRzZCU7hE][vídeo]]) ([[./exercicios/03/README.org][exercícios]])
- 19.03.2025 [[./aulas/04-variaveis/README.org][Aula 4: Variaveis e ponteiros]] ([[https://youtu.be/i7RKtMgSSrM][vídeo]]) ([[./exercicios/04/README.org][exercícios]])
- 21.03.2025 [[./aulas/05-controle/README.org][Aula 5: Estruturas de controle de fluxo]] ([[https://youtu.be/9dvDL7FbYKY][vídeo]]) ([[./exercicios/05/README.org][exercícios]])
- 26.03.2025 [[./aulas/06-vetores/README.org][Aula 6: Vetores]] ([[https://youtu.be/W5TGNQYFs4E][vídeo]]) ([[./exercicios/06/README.org][exercícios]])

View file

@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdarg.h>
// Função variádica (número indeterminado de argumentos)...
float vf_avg(int count, ...);
@ -8,8 +9,6 @@ float vf_avg(int count, ...);
float cf_avg(float a, float b, float c, float d);
int main(void) {
float nota1 = 7.5;
@ -35,9 +34,10 @@ int main(void) {
}
// Função comum...
float cf_avg(float a, float b, float c, float d) {
return (a + b + c + d) / 4;
}
// Função variádica...
float vf_avg(int count, ...) {
@ -53,7 +53,3 @@ float vf_avg(int count, ...) {
}
// Função comum...
float cf_avg(float a, float b, float c, float d) {
return (a + b + c + d) / 4;
}

View file

@ -6,7 +6,7 @@
* Aula 6: Vetores
[[][Vídeo desta aula]]
[[https://youtu.be/W5TGNQYFs4E][Vídeo desta aula]]
Vetores são estruturas de dados que agrupam valores do mesmo tipo na forma
de listas.

34
aulas/06-vetores/testes.c Normal file
View file

@ -0,0 +1,34 @@
#include <stdio.h>
#define NBIM 4
float favg(float *arr, int size) {
float sum = 0;
for (int i = 0; i < size; i++) {
sum += arr[i];
}
return sum / size;
}
int main(void) {
float notas[NBIM];
notas[0] = 7.5;
notas[1] = 9.0;
notas[2] = 8.3;
notas[3] = 8.6;
float avg = favg(notas, NBIM);
puts("============");
for (int i = 0; i < NBIM; i++)
printf("Bim. %d: %.1f\n", i + 1, notas[i]);
puts("------------");
printf("Média : %.1f\n", avg);
puts("============");
return 0;
}

View file

@ -19,7 +19,7 @@
vetor = endereço na memória ↑ ↑ ↑ ↑ ↑
Total de 16 bytes +----- 4 bytes -----+----- 4 bytes -----+----- 4 bytes -----+----- 4 bytes -----+
↑ ↑
&vetor+0 &vetor+4 (*)
&vetor+0 &vetor+1 (*)
(*) Problema: acesso fora dos limites do vetor!