Answer to Question #348559 in C++ for Hasnat

Question #348559

Create an array of size 12. Swap values of 8th and 11th index and display the changed array on screen.

1
Expert's answer
2022-06-10T08:30:04-0400
#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]<<" ";
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS