Question: Write a program that reads a list of integers from input and outputs the list with the first and last numbers swapped. A negative one

Write a program that reads a list of integers from input and outputs the list with the first and last numbers swapped. A negative one (-1) indicates the end of the input and should not be stored in the array. Assume the list contains fewer than 20 integers.
Ex: If the input is:
12345678-1
the output is:
82345671
For coding simplicity, follow every output value by a space, including the last one. The output should end with a newline.
Note: your program must input all the values into the array, and then change (modify) the first and last elements in the array, and then output the resulting modified array.
Do not use functions. Do not use vectors.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!