This one works (once the simple compile-time errors have been fixed)! Ensure you understand the important difference between Example 21 and Example 19.
/* This programme finds the sum of two vectors and prints out the
result. */
#include <stdio.h>
int vecA[4] = {1,2,3,4}, vecB[4] = {90,91,92,93};
void vecadd(int *a1, *a2, *sum) {
int i;
for (i = 0; i < 4; i++)
sum[i] = a1[i] + a2[i];
}
main() {
int ans[4];
int i;
vecadd(vecA, vecB, ans);
for (i = 0; i < 4; i++)
printf("%d \n", ans[i]);
}
|
| ...previous | cont's... |