Compare commits

..

No commits in common. "02c7f15a6679370953cf3293aca7d387ab112657" and "7560d3a58c9ac22468520308d32995411d8fd42b" have entirely different histories.

5 changed files with 11 additions and 42 deletions

View file

@ -25,4 +25,3 @@ 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,7 +1,6 @@
#include <stdio.h>
#include <stdarg.h>
// Função variádica (número indeterminado de argumentos)...
float vf_avg(int count, ...);
@ -9,6 +8,8 @@ float vf_avg(int count, ...);
float cf_avg(float a, float b, float c, float d);
int main(void) {
float nota1 = 7.5;
@ -34,10 +35,9 @@ 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,3 +53,7 @@ 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
[[https://youtu.be/W5TGNQYFs4E][Vídeo desta aula]]
[[][Vídeo desta aula]]
Vetores são estruturas de dados que agrupam valores do mesmo tipo na forma
de listas.

View file

@ -1,34 +0,0 @@
#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+1 (*)
&vetor+0 &vetor+4 (*)
(*) Problema: acesso fora dos limites do vetor!