CPPForSchool.com: Array - Single Dimension Set 1 Assignment 2

2. Write a C++ program to swap first and last element of an integer 1-d array.


This assignment was not too difficult, but it did take some time for me to figure how to reference the last element value.  Luckily, I was able to simply use "x-1" in order to reference the last value.  Nevertheless, I have continued to use my base template in regards to coding style.  Everything has been broken into functions.  Also, I used a lot of the same code from the prior assignment in order to create this assignment. 





It is important to note that I commented out the initial test code to ensure I understood how to execute this task at a very base minimal level.  Learning from the prior assignment, I reused the temp1/temp2 variables in order to store the values accordingly.





Here is the sample source code for comparison.




Comments

Popular posts from this blog

CPPForSchool.com: Variable, Operator & Expression Set 1: Assignment 9

CPPForSchool.com: Array - Single Dimension Set 1 Assignment 6

CPPForSchool.com: Variable, Operator & Expression Set 1: Assignment 8