Question #176200

write a c++ program that takes array values as an input .for each array element, find the difference between that element and last array element and update the array.

array can be of any size.

example:

input array: 1, 4, 5, 6, 7, 2


Expert's answer

#include <iostream>
 
using namespace std;
 
int main()
{
	int size = 0;
	cout << "Enter size of Array: ";
	cin >> size;
	int* a = new int[size];
	cout << "Enter Array's elements to separate values use spaces." << endl;
	cout << "Input array: ";
	for (int i = 0; i < size; i++)
	{
		cin >> a[i];
	}
	cout << "Updated array: ";
	for (int i = 0; i < size; i++)
	{
		a[i] -= a[size - 1];
		cout << a[i] << " ";
	}
	cout << endl;
 
	return 0;
}

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!

LATEST TUTORIALS
APPROVED BY CLIENTS