老師出了一道題目:Write four functions: getArray to read in a floating-point arrays with 12 numbers from keyboard, 2nd function findAver to calculate the average of this arrays and return the result, third function findMin and last function output to print out this array onto the screen. Also write a main function to test your design:
function prototype :
void getArray(float data[ ], int size) ;
float findAver(float data[ ], int size) ;
float findMin(float data[ ], int size) ;
void output(float data[ ], int size) ;
我寫出來的程式:
#include <stdio.h>
void getArray(float data[ ], int size){
int i,arr[12],sum=0;
printf("Enter 12 elements:");
for(i=0;i<12;++i)
scanf("%d",&arr[i]);
for(i=0;i<12;++i)
sum=sum+arr[i];
printf("Sum of numbers is:%d",sum);
}
float findAver(float data[ ], int size){
int sum;
printf("Aver of numbers is:%f",sum/12);
}
float findMin(float data[ ], int size){
int i,min=1001;
for(i=0;i<l2;i++)
if(array[i]<min) min=array[i];
printf("min%d",min);
return 0;
}
int main(){
void getArray(float data[ ], int size);
float findAver(float data[ ], int size);
float findMin(float data[ ], int size);
void output(float data[ ], int size);
return 0;
}
而編譯器顯示for(i=0;i<l2;i++)中的12未申明,希望大神能幫忙