In: Computer Science
Please follow the instructions and solve it by c++
Close the project and create a new one called 'Lab0-Part3' with the same options as in the previous step. Write a C++ program that does the following:
#include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main() { // Creates a 100-element array, either statically or dynamically int arr[100]; // Fills the array with random integers between 1 and 100 inclusive srand(time(NULL)); for (int i = 0; i < 100; ++i) { arr[i] = 1 + (rand() % 100); } // Then, creates two more 100-element arrays, one holding odd values and the other holding even values. int odds[100], evens[100], oddCount = 0, evenCount = 0; for (int i = 0; i < 100; ++i) { if (arr[i] % 2 == 0) { evens[evenCount++] = arr[i]; } else { odds[oddCount++] = arr[i]; } } // Prints both of the new arrays to the console. cout << "Odd array: "; for (int i = 0; i < oddCount; ++i) { cout << odds[i] << " "; } cout << endl; cout << "Even array: "; for (int i = 0; i < evenCount; ++i) { cout << evens[i] << " "; } cout << endl; return 0; }