fork download
  1. #include <omp.h>
  2. #include <iostream>
  3.  
  4. int main(){
  5.  
  6. int tmp = 5;
  7. #pragma omp parallel for num_threads(4) private(tmp)
  8. for(int j = 0; j < 8; ++j) {
  9. tmp = tmp + j;
  10. }
  11. printf("Final value of tmp = %d \n", tmp);
  12. }
  13.  
Success #stdin #stdout 0.01s 5536KB
stdin
Standard input is empty
stdout
Final value of tmp = 33