forked from malep2007/C-Programming-Assignment
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQUESTION 4.c
More file actions
31 lines (27 loc) · 694 Bytes
/
QUESTION 4.c
File metadata and controls
31 lines (27 loc) · 694 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
/* solution to question four*/
void addarrays(int array1[], int array2[],int destination_array[],int size)
{
for(int i=0;i<size;i++){
destination_array[i]=array1[i]+array2[i];
}
}
/* modification of the program*/
# include<stdio.h>
int*addarrays(int array1[], int array2[],int size);
int main()
{
int array1[]={1,5,3,22,6};
int array2[]={13,143,11,10,121};
int*array3=addarrays(array1,array2,5);
for(int i=0;i<5;i++){
printf("%d",array3[i])
}
}
int*addarrays(int array1[],int array2[],int len)
{
int*destination_array=malloc(len*sizeof(int));
for(inti=0;i<len;i++){
destination_array[i]=array1[i]+array2[i];
}
return destination_array;
}