Hello if anyone could help me with this code, I would appreiciate. It asks for us to use CMDline arguments and swap the elements of an array in reverse order. for example (2 3 4 5 6) is (6 5 4 3 2).
Here is my code.
Code:#include <iostream> #include <stdlib.h> using namespace std; int reverse(int numpts, int array[]) { int temp; for (int i=0; i < numpts/2; i++) { temp = array[i]; array[i] = array[numpts-i-1]; array[numpts-i-1] = temp; } return temp; } int main(int argc, char *argv[]) { int npts = argc - 1; int x[50]; for (int i = 1; i < argc; i++) { x[i-1] = atoi(argv[1]); cout << argv[i] << endl; } cout << reverse (npts, x) << endl; system("PAUSE"); return 0; }