Create an array of size 12. Swap values of 8th and 11th index and display the changed array on screen.
#include <iostream>
using namespace std;
void SwapInt(int* x, int* y)
{
int temp = *x;
*x = *y;
*y = temp;
}
int main()
{
int arr[12];
cout << "Please, enter 12 values: ";
for (int i = 0; i < 12; i++)
{
cin >> arr[i];
}
SwapInt(&arr[8], &arr[11]);
cout << "Changed array: ";
for (int i = 0; i < 12; i++)
{
cout << arr[i]<<" ";
}
}
Comments
Leave a comment