Answers for "sum average min max in c array"

C
0

sum average min max in c array

#include <stdio.h>


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;
}
Posted by: Guest on July-13-2021

Code answers related to "C"

Browse Popular Code Answers by Language