Yes, something like that, but definitely not that:
Code:
unsigned int a[500];
unsigned int b[500];
int i;
unsigned int answer[];
unsigned int sum=0;
for ( i=0; i<=1000 ; i++)
{ answer[i]= a[i]*b[i];
sum= sum+answer[i];
}
Egad! Where are those other 500 numbers coming from? a and b are only defined for indexes 0 to 499, but your loop tries to index all the way through 999. Also, you should probably give answer a size. I reckon 500 would be good there too, once you change your loop. This sounds like a perfect opportunity to put in a plug for named constants (i.e. not bad juju magic numbers like 500 and 1000) and indentation:
Code:
#define SIZE 500 // hooray for constants...want to change the size? only one place to change it instead of 4
unsigned int a[SIZE];
unsigned int b[SIZE];
int i;
unsigned int answer[SIZE];
unsigned int sum = 0;
for (i = 0; i < SIZE; i++) {
answer[i] = a[i] * b[i];
sum += answer[i]; // that's shorthand for sum = sum + answer[i]
}