📌  相关文章
📜  c 数组中的求和平均值最小值最大值 - C 编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:37.940000             🧑  作者: Mango

代码示例1
#include 


int main(){
    int i,sum=0;
    //declaring array
    int score[7] = {67,55,98,88,90,76,89};
    //finding sum of the array numbers
    for(i = 0; i < 7; i++){
        sum = sum + score[i];
    }
    
    printf("Sum is %d\n",sum);
    
    //finding average
    printf("Average is %d\n",sum/7);
    
    //finding max number
    int max=score[0];
    for(i = 0; i < 7; i++){
        if(score[i] > max){
            max = score[i];
        }
    }
    
    printf("Max number is %d\n",max);
    
    //finding min number
    int min=score[0];
    for(i = 0; i < 7; i++){
        if(score[i] < min){
            min=score[i];
        }
    }
    printf("MIn number is %d\n",min);
    
    
    
    
    
    return 0;
}