Write a function that accepts an array of integers and determines the difference between the integers. For example, if the array [3 7 8 13 11] is passed to the function, it prints to the screen [3 4 1 5 -2].
mine give me : 3, 4 ,4 9, 2
but i cant see why its wrong! please help
#include <iostream>
using namespace std;
#define n 5
void ArraySub(double* MainArray)
{
int i;
for (i=1; i<n; i++)
{
MainArray[i] = MainArray[i] - MainArray[i-1];
}
}
int main(void)
{
double Array[n] = { 3, 10, 243, 8374, 102893};
ArraySub(Array);
for (int i=0; i<n; i++)
{
cout << Array[i] << endl;
}
return 1;
}