You are viewing a single comment's thread. Return to all comments →
using namespace std; void reversearrays(int arr[], int n) { int s = 0; int e = n - 1; while (s <= e) { swap(arr[s], arr[e]); s++; e--; }
} void printarray(int arr[], int n) { for (int i = 0; i < n; i++) { cout << arr[i] << ' '; } }
int main() { int n; cin >> n; int* arr = new int[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; }
reversearrays(arr, n); cout << endl; cout << "Array elements after reversing " << endl; printarray(arr, n); return 0;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Arrays Introduction
You are viewing a single comment's thread. Return to all comments →
include
include
include
include
include
using namespace std; void reversearrays(int arr[], int n) { int s = 0; int e = n - 1; while (s <= e) { swap(arr[s], arr[e]); s++; e--; }
} void printarray(int arr[], int n) { for (int i = 0; i < n; i++) { cout << arr[i] << ' '; } }
int main() { int n; cin >> n; int* arr = new int[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; }
}