#include <stdio.h>
#include <omp.h>
#define N 4 // Matrix size
int main() {
int A[N][N], sum = 0;
// Initialize matrix
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++)
A[i][j] = i + j + 1;
// Parallel sum using OpenMP
#pragma omp parallel for reduction(+:sum)
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++)
sum += A[i][j];
printf("Sum of Matrix: %d\n", sum
); return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxvbXAuaD4KCiNkZWZpbmUgTiA0ICAvLyBNYXRyaXggc2l6ZQoKaW50IG1haW4oKSB7CiAgICBpbnQgQVtOXVtOXSwgc3VtID0gMDsKCiAgICAvLyBJbml0aWFsaXplIG1hdHJpeAogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBOOyBpKyspCiAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCBOOyBqKyspCiAgICAgICAgICAgIEFbaV1bal0gPSBpICsgaiArIDE7CgogICAgLy8gUGFyYWxsZWwgc3VtIHVzaW5nIE9wZW5NUAogICAgI3ByYWdtYSBvbXAgcGFyYWxsZWwgZm9yIHJlZHVjdGlvbigrOnN1bSkKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgTjsgaSsrKQogICAgICAgIGZvciAoaW50IGogPSAwOyBqIDwgTjsgaisrKQogICAgICAgICAgICBzdW0gKz0gQVtpXVtqXTsKCiAgICBwcmludGYoIlN1bSBvZiBNYXRyaXg6ICVkXG4iLCBzdW0pOwogICAgcmV0dXJuIDA7Cn0=