### Multiply the elements of two arrays

Hi all,

I am trying to multiply two array values for 10 different values, but only the first one is nonzero, others are all 0.

 ``1234567891011121314151617181920212223242526`` ``````int numS =10; int x[15] = {3,4,6,7,8,9,7,6,4,3,2,1,1,4,5}; int C[10][15]= { {10,14,15,11,1,0,89,0,909,0,0,1,1,0,0}, {17,1,17,16,15,31,0,0,42,420,0,142,1,0,0}, {1,0,0,1,15,0,0,53,1,321,1,135,1,0,0}, ... }; void Function(int numS) { int i,j; for(i = 0; i < numS; i++) { for(j = 0; j < 15; j++) { result[i] += double(C[i][j]*x[j]); } for(i = 0; i < numS; i++) { cout <

What is wrong in this code? Thanks
 ``123456789101112`` `````` int i,j; for(i = 0; i < numS; i++) { //... for(i = 0; i < numS; i++) //When this loop ends, i=numS { cout <
So, the updated code:

 ``123456789101112131415161718192021222324252627`` ``````int numS =10; int x[15] = {3,4,6,7,8,9,7,6,4,3,2,1,1,4,5}; int C[10][15]= { {10,14,15,11,1,0,89,0,909,0,0,1,1,0,0}, {17,1,17,16,15,31,0,0,42,420,0,142,1,0,0}, {1,0,0,1,15,0,0,53,1,321,1,135,1,0,0}, ... }; void Function(int numS) { int i,j; for(i = 0; i < numS; i++) { for(j = 0; j < 15; j++) { result[i] += double(C[i][j]*x[j]); } for(i = 0; i < numS; i++) { cout <

It still gives the same result. Did I misunderstand it?
Topic archived. No new replies allowed.