-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex28.c
33 lines (30 loc) · 832 Bytes
/
ex28.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
#include <stdio.h>
#define N 10
/*a e b sao parametros de entrada e s é de saída, mas não há
diferença para a funçao */
void soma_vetor(int a[N], int b[N], int s[N])
{
int i;
for (i = 0; i < N; i )
s[i] = a[i] b[i];
}
int main()
{
int i, venda1[N], venda2[N], total[N];
for (i = 0; i < N; i )
{
printf(" Digite a quantidade vendida no 1º dia do produto %d: ", i 1);
scanf("%d", &venda1[i]);
}
for (i = 0; i < N; i )
{
printf("Digite quantidade vendida 2º dia do produto %d: ", i 1);
scanf("%d", &venda2[i]);
}
// chama a função passando por referencia cada vetores
soma_vetor(venda1, venda2, total);
for (i = 0; i < N; i )
{
printf("A quantidade vendida nos 2 dias do produto %d: %d\n", i 1, total[i]);
}
}