In: Computer Science
Identify all private and shared variables in the following code snippet. What is the output of the program (e.g. the value of res)?
// =========
int A[100];
int count;
void work(int index[])
{
float B[10];
……
}
void main(){
int res = 10;
#pragma omp parallel
{
int index[10], i=0, IS=0;
work(index);
#pragma omp for
for(i=0;i<100;i++)
{
IS = IS + i;
}
#pragma omp critical
res += IS;
}
cout << res << endl;
}
View keyboard shortcuts
The given code has been recreated in C++ and the output of the program as below as screenshot .
Identified private and shared variables are shown as commented lines in the C++ code below screenshot .