By assuming that you have an array like arr[n]
:
You can define another array to keep differences like diff[n-1]
and then you just need a loop like:
for(i=0; i<n-1; i++) {
diff[i] = abs(arr[i]-arr[i+1]);
}
Don’t forget to include <stdio.h>
and <stdlib.h>
.
0
solved Absolute difference between consecutive array elements