Doing calculations with arrays - invalid operands to binary
Posted on 2008-06-10
I'm new to C programming but feel i'm pretty good at perl so I feel like I really should be able to do this.
I've looked at C tutorials and in several text books but I can't find anything which helps.
All I want to do is do some calculations with arrays of data.
for (i=1; i<=d; i++)
a[i] = b[i] / c[i];
Why does this give me the error message: invalid operands to binary /. I'm using Dev-C++.
The division seems to be causing a problem.
I've tried all data types. I want to use double or float.
I'm adding to an existing C program and earlier in the program there is this code:
for (i=1; i<=x; i++)
y[i] = z[i] / t;
This works but mine doesn't.
This type of thing is easy in perl but i've spent ages on this.
Can anyone tell me how to work through arrays and perform calculations on each element or point me to a useful website. Thanks