/* Compute the sum of the elements of the array */
#include <stdio.h>
#define SIZE 4

main()
{
   int a[SIZE];
   int i, total = 0;
   FILE *fp,*fw;
   
   fp = fopen("sample","r");
   fw = fopen("samplew","w");

   for (i = 0; i <= SIZE - 1; i++)
      {
        fscanf(fp,"%d",&a[i]);
        fprintf(fw,"%d\n",a[i]);
        total += a[i];
      }

   printf("Total of array element values is %d\n", total);
   fclose(fp);
   fclose(fw);

   return 0;
}

