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
file "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 undefined 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:
http://i36.tinypic.com/1roldu.jpg
Now what I currently have is
Code:
#include <stdio.h>
FILE *inp;
main()
{
int i, k, j, x[10], y[10], z[19];
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++)
{
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.
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?