====== C - C++ Adjacent differences of elements in array ====== #include #include #include using namespace std; int diff (int x, int y) {return x+y;} int main () { int a[] = {1,2,3,4,5,6,7,8,9,10}; int b[10]; cout<<"Given Elements:"; for (int i=0; i<10; i++) cout << a[i] << ' '; adjacent_difference (a, a+10, b); cout << "\nDifference between adjacent numbers:"; for (int i=0; i<10; i++) cout << b[i] << ' '; cout << endl; adjacent_difference (a, a+10, b, multiplies()); cout << "Multiplying adjacent numbers using adjacent_difference: "; for (int i=0; i<10; i++) cout << b[i] << ' '; cout << endl; adjacent_difference (a, a+10, b, diff); cout << "adding adjacent numbers using adjacent_difference:"; for (int i=0; i<10; i++) cout << b[i] << ' '; cout << endl; cout<<"Partial Sum:"; partial_sum(&a[0], &a[10], &b[0]); for (int i=0; i<10; i++) cout << b[i] << ' '; return 0; }