• First, create a function called addNumber, which has a formal parameter for an array of integers and increase the value of each array element by a random integer number between 1 to 10. o Add any other formal parameters that are needed. • Second, create another function called printReverse that prints this array in reverse order. • Then, you need to write a C++ program to test the use of these two functions.
#include <iostream> #include <cstdlib> #include <ctime> using namespace std; void addNumber(int arr[], int size) { for (int i = 0; i < size; ++i) { arr[i] += 1 + (rand() % 10); } } void printReverse(int arr[], int size) { for (int i = 0; i < size; ++i) { cout << arr[size-i-1] << " "; } cout << endl; } int main() { srand(time(NULL)); int arr[] = {5, 9, 1, 2, 7, 6}, size = 6; printReverse(arr, size); addNumber(arr, size); printReverse(arr, size); return 0; }
Get Answers For Free
Most questions answered within 1 hours.