forked from malep2007/C-Programming-Assignment
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquestion4.txt
More file actions
33 lines (27 loc) · 819 Bytes
/
Copy pathquestion4.txt
File metadata and controls
33 lines (27 loc) · 819 Bytes
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>
void addarrays(int [], int[], int*);
int main(){
int counter;
int a[] = {1,2,3};
int b[] = {8,5,8};
int size = (int)sizeof(b)/4; // i divided by 4 because the size of function gives the total number of bytes in the array
int c[size];
// for (counter = 1; counter < MAXVALUES; counter++ )
// printf("\nCounter = %d", counter);
if ((int)sizeof(a)==(int)sizeof(b)){
addarrays(a,b,c);
for (counter = 0; counter < size; counter++ ){
printf("\n %d", c[counter]);
}
}else{
printf("input array of same size");
}
return 0;
}
void addarrays(int a[], int b[], int* c){
int i ;
for (i=0; i<sizeof(a) ; i++){
*c = a[i] + b[i];
c++;
}
}