C

an anonymous user · July 22, 2021 · C
#include <stdio.h>
public int findtotalsum(int input1, int[] input2){
    int sum =0;
    int i=0;
    for(i=0;i<input1-1;i++){
       sum += abs(input2[i] - input2[i+1]); 
    }
    return sum;
}
int main() {
   int n = 5;
   int[] a={10,11,7,12,14};
   int result = findtotalsum(n, a);
   printf(result);
}

Comments

Please sign up or log in to contribute to the discussion.