To swap the 3rd and 4th elements in the int array values you

To swap the 3rd and 4th elements in the int array values, you would do:

values[3] = values[4];
values[4] = values[3];

Solution

No, this is wrong attempt. As the value of 3rd element is not being saved any where this would be done by a temp variable.

temp=values[3];

values[3]=values[4];

values[4]=temp;

this will produce correct result.

To swap the 3rd and 4th elements in the int array values, you would do: values[3] = values[4]; values[4] = values[3];SolutionNo, this is wrong attempt. As the v

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site