• + 0 comments

    include

    using namespace std;

    void reverse(int arr[], int n) { // Change return type to void int start = 0; int end = n - 1; int temp; while (start < end) { temp = arr[start]; arr[start] = arr[end]; arr[end] = temp; start++; end--; } }

    int main() { int arr[] = {2, 3, 4, 5, 6, 7, 8}; int n = sizeof(arr) / sizeof(arr[0]);

    reverse(arr, n);  // Call the reverse function
    
    // Print the reversed array
    for (int i = 0; i < n; i++) {
        cout << arr[i] << " ";
    }
    cout << endl;
    
    return 0;
    

    }