Question: In C++ please, and i need EXACT results! Warning: do not use vectors in this exercise. Write a program that takes a list of integers
In C++ please, and i need EXACT results!
Warning: do not use vectors in this exercise.
Write a program that takes a list of integers as input from the user. The input begins with an integer indicating the number of integers that follow. You can safely assume that the number of integers input is always less than or equal to 10.
(1) Store the input integers (except for the first one) into an array, output the elements in this array. For coding simplicity, follow each output integer by a whitespace, including the last one.
Ex: if the input is:
6 1 2 3 4 5 6
then the program will output:
1 2 3 4 5 6
(2) Swap each element with an even index starting from index 0 with the one at its immediate right. That is, swap index 0 element with index 1 element, index 2 element with index 3 element, etc.. Given the above input integers, the output after this operation should be
2 1 4 3 6 5
If the input has an odd number of integers, the last extra element will not be swapped. For example, if the input is:
5 1 2 3 4 5
the the program will output:
1 2 3 4 5 2 1 4 3 5
The first line outputs the original array, while the second line shows the array after swapping.
Any attempt to hard code answers will result in a 0 for the exercise.

Warning: do not use vectors in this exercise. Write a program that takes a list of integers as input from the user. The input begins with an integer indicating the number of integers that follow. You can safely assume that the number of integers input is always less than or equal to 10. (1) Store the input integers (except for the first one) into an array, output the elements in this array. For coding simplicity, follow each output integer by a whitespace, including the last one. Ex: if the input is: 6 1 2 3 4 5 6 then the program will output: 1 2 3 4 5 6 (2) Swap each element with an even index starting from index 0 with the one at its immediate right. That is, swap index 0 element with index 1 element, index 2 element with index 3 element, etc.. Given the above input integers, the output after this operation should be 2 1 4 3 6 5 If the input has an odd number of integers, the last extra element will not be swapped. For example, if the input is: 5 1 2 3 4 5 the the program will output: 1 2 3 4 5 2 1 4 3 5 The first line outputs the original array, while the second line shows the array after swapping. Any attempt to hard code answers will result in a 0 for the exercise
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
