Computing.Net > Forums > Programming > array in C

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

array in C

Reply to Message Icon

Name: leon
Date: January 8, 2003 at 13:30:19 Pacific
OS: xp
CPU/Ram: 1.2G/256
Comment:

Hi, i have a problem with my array. i got a 2d array. array[49][14]. i need to find out the value of something like this: array[0][j]*0+array[1][j]*1+array[2][j]*2+...+ array[48][j]*48, where the value of j goes form 0 to 13 (that is sum of each elements in the array times the x coordinate of the array) . i write a code using for loop. but i keep getting 0. i think my code is wrong. would anyone please take a look at it? thanks!

sum_zx = 0;
for (i=0; i < 49; ++i)
for (j=0; j < 14; ++j)
sum_zx = sum_zx + j*array[i][j];



Sponsored Link
Ads by Google

Response Number 1
Name: quackadilly
Date: January 8, 2003 at 20:44:14 Pacific
Reply:

the sum of the data in row 1 or (0) for array of size [49][14] :

array[49][14]

-
int sum=0;

for(int i;j<14;i++){
sum=array[0][j]*j + sum;
}
-

Note: this is how I'd do it in C++


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: array in C

How to use string array in C++? www.computing.net/answers/programming/how-to-use-string-array-in-c/9478.html

vector of arrays in c++ www.computing.net/answers/programming/vector-of-arrays-in-c/12919.html

Dynamic Arrays in C www.computing.net/answers/programming/dynamic-arrays-in-c/3396.html