#include #define N 5 void main() { inti, X[N]; for (i=0; i < N; i++) { /* รับข้อมูล */ printf(“Enter number : ”); scanf(“%d”, &X[i] ); } for (i=0; i < N; i++) { /* แสดงข้อมูลพร้อมตำแหน่ง */ printf(“address of X[%d] is %x \t ”, i, &X[i]); printf(“its content is %d \n\n ”, X[i]); } getch(); }
#include #define N 5 void Readdata(int *, int); float Average(int *, int); void Display(int *, int, float); void main( ) { int X[N]; float Mean; Readdata(X, N); Mean = Average(X, N);Average(X, N); Display(X, N, Mean); getch(); } การเรียกใช้ ฟังก์ชัน Function’s Prototype x ????? 80880A80C80E mean 5.0
void Readdata(int y[ ], int n) { int i; for (i=0; i < n; i++) { printf(“Enter number : ”); scanf(“%d”, &y[i]); } n 5 i 0 y 80880A80C80E
float Average (int y[ ], int n) { int i, s ; for (i=0, s=0; i<n; i++) s += y[i]; return s/n;return s/n } y n 5 i 0 s A80C80E
void Display (int y[], int n, float mean) { int i; for (i=0; i<n; i++) { printf(“X[%d] is %d ”, i, y[i] ); if (y[i] < mean) then printf(“*”); printf(“\n”) } getch(); } y n A80C80E810 mean 5.0