알고리즘 24 - Calculate average

tamagoyakii·2021년 10월 8일
0

알고리즘

목록 보기
24/89

Q.

Write a function which calculates the average of the numbers in a given list.

Note: Empty arrays should return 0.

A)

double find_average(double* array, int length) {
  double average = 0;
  for (int i = 0; i < length; i++)
    average += array[i];
  return average / length;
}

0개의 댓글