whatsapp

Connect on Whatsapp : +1 206 673 2541, Get Homework Help 24x7, 100% Confidential. Connect Now

C++ Function programming | Computer Science homework help

C++ Function with Array Parameters Problem:

Write a function SwapArrayEnds() that swaps the first and last elements of the function’s array parameter.

  1. Ex: sortArray = {10, 20, 30, 40} becomes {40, 20, 30, 10}.

 

The array’s size may differ from 4. Here is what is given:

  1. #include using namespace std;
  2.  /* Your solution goes here */
  3. int main()
  4. {
  5. const int SORT_ARR_SIZE = 4; int sortArray[SORT_ARR_SIZE];
  6. int i = 0;
  7. sortArray[0] = 10;
  8. sortArray[1] = 20;
  9. sortArray[2] = 30;
  10. sortArray[3] = 40;
  11. SwapArrayEnds(sortArray, SORT_ARR_SIZE);
  12. for (i = 0; i < SORT_ARR_SIZE; ++i)
  13. {
  14. cout << sortArray[i] << ” “;
  15. }
  16. cout << endl; return 0;
  17. }

Get FREE Essay Price Quote
Pages (550 words)
Approximate price: -