I am writing a program that multiplies two Matrice's and the third Matrix prints the results. Along with that I want to compute the arithmetic operation time that I specified in my code below, however I keep getting a segmentation fault and I believe I am using the time.h/clock() library function correctly. Ive provided a snippet of the section giving me problems.
/** Third Matrix **/
for (i = 0; i < N; i++) {
for (x = 0; x < N; x++) {
arr3[i][x] = 0;
for (y = 0; y < N; y++)
arr3[i][x] = arr3[i][x] + arr1[i][y] * arr2[y][x];
}
}
arithmeticBegin = clock(); //begins the clock for arithmetic time
//the following line is what was causing the seg fault
arr3[i][x] = arr3[i][x] + arr1[i][y] * arr2[y][x];
arithmetic_endTime = clock(); //stops the clock for the end of arithmetic time
/** The following computers total arithmetic Time **/
arithmeticTime += (double)(arithmetic_endTime - arithmeticBegin) / CLOCKS_PER_SEC;