-
Notifications
You must be signed in to change notification settings - Fork 0
/
3sem.ex02.c
52 lines (43 loc) · 914 Bytes
/
3sem.ex02.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
49
50
51
52
#include <stdio.h>
#include <stdlib.h>
/* PROTOTYPES */
int ler_num ( int v[], int num);
int imprimir_num ( int v[], int num );
float calc_media ( int v[], int num);
int ler_num ( int v[], int num )
{
for (int i = 0; i < num; i++ )
{
//printf("Digite um numero: \n");
scanf("%d",&v[i]);
}
return 0;
}
int imprimir_num ( int v[], int num )
{
for ( int i = 0; i < num; i++ )
{
printf("%d ",v[i]);
}
return 0;
}
float calc_media ( int v[], int num)
{
float cont = 0;
for ( int i = 0 ; i < num; i++ )
{
cont += v[i];
}
return cont / num;
}
int main()
{
int vetor[5];
float media;
size_t tam = sizeof(vetor)/sizeof(vetor[0]);
ler_num(vetor,tam);
imprimir_num(vetor,tam);
media = calc_media(vetor,tam);
printf("%.2f \n",media);
return 0;
}