Example 21

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]);
    }

...previouscont's...



About this document:

Produced from the SGML: /home/isd/public_html/_course_crash_in_c/_reml_grp/practical_c.reml_lib
On: 3/3/2003 at 16:27:16
Options: reml2 -i noindex -l long -o html -p multiple