Hello, I'm currently a student with a beginner programming skill level and have trouble with programming problem.
The problem is:
Let X and Y be two arrays of size 10. Let Z be an array of size 19. The values of arrays X and Y are available in the
ﬁle "input-xy.txt", where every line contains three values: (1) index of the array, i -- an integer; (2) value of element
in array x, x[i] -- a double value, and (3) value of element i in array y, y[i] -- a double value. The value of x and y ele-
ments for undeﬁned indices are assumed to be zero.
Element j of array z, z[j] is computed as below: j = 0, 1, 2, . . . , 18.
for the summation:
Now what I currently have is
What I want to know does everything look alright? I'm making my k max equal 0 for 0<j<9 so everything would be simplified. That would be all my values for x are less than or equal to 9.
int i, k, j, x, y, z;
int sum = 0
inp = fopen("input-xy.txt", "r");
fscanf(inp, "%d ", &b);
fscanf(inp, " %d %d ", &x[b], &y[b]);
printf(" %d %d %d ", b, &x[b], &y[b]);
for ( j = 0; j <= 9; j++)
k = 0;
z[j] = x[k] * y[j-k];
for ( j = 11; j <=19; i++)
But also can I do this:
z[j] = x[k] * y[j-k] in the for loop? Can I write a function with the array bracket?