Thanks for the suggestion....Here is the code which is giving segmentation fault error(core dump)
Source Code
#include<stdio.h>
#include<omp.h>
int main()
{
int A[1000000],B[1000000],C[1000000];
int I;
double start,end,seq,par;
for(I=1;I<=1000000;I++)
{
A[I]=I;
B[I]=I;
}
start=omp_get_wtime();
for(I=1;I<=1000000;I++)
C[I]=A[I]+B[I];
end=omp_get_wtime();
seq=(end-start);
start=omp_get_wtime();
#pragma omp parallel for
for(I=1;I<=1000000;I++)
C[I]=A[I]+B[I];
end=omp_get_wtime();
par=(end-start);
printf("sequential time execution is=%lf",seq);
printf("parallel time execution is=%lf",par);
printf("\n the elements of array A are:\n");
for(I=1;I<=20;I++)
printf("%5d",A[I]);
printf("_ _ _ _ _ _ 1000000\n");
printf("\n the elements of array B are:\n");
for(I=1;I<=20;I++)
printf("%5d",B[I]);
printf("_ _ _ _ _ _ 1000000\n");
printf("\n the elements of array C are:\n");
for(I=1;I<=20;I++)
printf("%5d",C[I]);
printf("\n time taken for sequential execution=%lf secs",seq);
printf("\n time taken for parallel execution=%lf secs",par);
} 1,1 Top