Here is the code as you can see, I am not able to run it, its throwing error.
#include <iostream>
#include <thread>
using namespace std;
int sum = 0;
int arr[500];
for (int i = 0; i < 500; i++) {
arr[i] = rand() % 100;
cout << arr[i] << endl;
void arraySum() { sum = sum + arr[i]; }
}
main() {
std::thread t1(arraySum);
t1.join();
for (int i = 0; i < 10; i++) {
cout << "Sum of : " << sum;
}
}
Aucun commentaire:
Enregistrer un commentaire