I am trying to a simple addition function that will take a number x from an array an and add a variable i to it, which is the iteration variable inside the for loop. Instead of adding each variable individually and producing the output of :
3, 2, 7
it produces values of
3, 5, 13.
#include <stdio.h>
int add(int x[], int y);
int main(void) {
int i;
int a[3] = {3, 1, 5};
for(i=0; i<3; i++)
{
printf("%d \t", i);
printf("%d, %d, equals %d \n", a[i], i, add(a[i], i));
}
return 0;
}
int add(int x[], int y){
return x+y;
}