iT邦幫忙

0

C語言 函式 矩陣 問題請教

老師出了一道題目: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未申明,希望大神能幫忙

1 個回答

0
海綿寶寶
iT邦大神 1 級 ‧ 2020-12-01 22:51:18

應該是 12 而不是 l2

1 跟 l 位置差很遠
不太會有人打錯字才是

真相永遠只有一個

我要發表回答

立即登入回答