Answer to Question #176200 in C++ for abhishek jaswal

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


1
Expert's answer
2021-03-27T11:41:29-0400
#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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS