Professional Documents
Culture Documents
#include<stdio.h>
#include<omp.h>
#include<stdlib.h>
int main()
{
int a[10],b[10],c[10],n,i,j;
printf("Enter the size of the vectors \n");
scanf("%d",&n);
OUTPUT:
IMPORTANT POINTS:
There are four variables i,j, n , a and b,c . The data-sharing attribute of
variables, which are declared outside the parallel region, is usually shared.
Therefore, n and a,b are shared variables. The loop iteration variables, however,
are private by default. Therefore, i is private. The variables which are declared
locally within the parallel region are private. Thus c is private.
int main()
{
int a[10],b[10],c[10],n,i,j;
printf("Enter the number of dimentions \n");
scanf("%d",&n);
OUTPUT:
IMPORTANT POINTS
There are four variables i,j, n , a and b,c . The data-sharing attribute of
variables, which are declared outside the parallel region, is usually shared.
Therefore, n and a,b are shared variables. The loop iteration variables, however,
are private by default. Therefore, i is private. The variables which are declared
locally within the parallel region are private. Thus c is private.
for(i=0;i<n;i++)
S[i]=a[i]+b[i];
}
for(i=0;i<n;i++)
cout<<S[i]<<" ";
cout<<"/n";
return 0;
}
OUTPUT
IMPORTANT POINTS:
The shared(list) clause declares that all the variables in list are shared.
b,S and a are shared variables.