The code I wrote for this is:
#include <stdio.h>
#include <time.h>
int main(void) {To compile the code on archie we use the following compiler command:
srand(time(NULL));
int arraySize = 1000;
int arrayOne[arraySize], arrayTwo[arraySize], arrayThree[arraySize];
for (int i = 0; i < arraySize; i++) {
arrayOne[i] = rand() % 1000;
arrayTwo[i] = rand() % 1000;
}
for (int j = 0; j < arraySize; j++) {
arrayThree[j] = arrayOne[j] + arrayTwo[j];
}
long sum = 0;
for (int k = 0; k < arraySize; k++) {
sum += arrayThree[k];
}
printf("%d\n", sum);
return 0;
}
gcc -x c vec.C -o vec -O3 -std=c99 -gI have not yet tested the code on archie, and only on my own pc. So that's on my TO-DO list.
No comments:
Post a Comment