#include <stdio.h>
int function(int *ptr, int n);
int main(void) {
    int data[5]={50, 20, 40, 30, 10};
    int result, length;
    result = function(data, 5);
    length = sizeof(data) / sizeof(data[0]);
    printf("%d", result/length);               // 150/5 =30
    return 0;
}
int function(int *ptr, int n){
    int i, temp=0;
    for(i=0; i<n; i++)
        temp += *(ptr+i);                     //data 배열의 값을 모두 합한 결과
    printf("%d ", temp);
    return temp;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: