forked from malep2007/C-Programming-Assignment
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq4b.c
More file actions
50 lines (42 loc) · 971 Bytes
/
q4b.c
File metadata and controls
50 lines (42 loc) · 971 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <stdio.h>
#include <stdlib.h>
int results[] = {};
int *addarrays(int array1[], int array2[], int n);
int main(void) {
int i,n;
printf("Enter the size of the arrays: \n");
scanf("%d",&n);
int array_first[n], array_second[n];
printf("Enter First array: \n");
for ( i = 0; i < n; i++) {
scanf("%d", &array_first[i]);
}
printf("Enter Second array: \n");
for ( i = 0; i < n; i++) {
scanf("%d", &array_second[i]);
}
int *y;
y = addarrays(array_first, array_second, n);
printf("array one: ");
for (i=0; i < n ; i++) {
printf("%d,", array_first[i]);
}
printf("\n array two: ");
for (i=0; i < n; i++){
printf("%d,", array_second[i]);
}
printf("\nresults array: ");
for (i=0; i < n; i++){
printf("%d,", y[i]);
}
return 0;
}
int *addarrays(int array1[], int array2[], int n) {
int i = 0;
for (i = 0; i < n; i++) {
results[i] = array1[i] + array2[i];
}
int *z;
z = results;
return z;
}